The high-school polynomial division algorithm works over any commutative coefficient ring, as long as the divisor $g$ has invertible leading coefficient. Then the leading term of $g$ always divides any monomial of higher degree, thus the high-school division algorithm works to kill all higher degree terms in the dividend, leaving a remainder of degree smaller than $\,\deg g$.
Alternatively we can reduce to the case where the divisor $\,g\,$ is monic (lead coef $= 1)$ as follows. Make the divisior $g$ monic by dividing it by its lead coef $c,\,$ then divide by the monic $\,g/c\,$ yielding $\, f = q(g/c)+ r = (q/c) g + r\,$ as desired, after moving the division by $\,c\,$ into the quotient.
The division algorithm generally fails if the lead coef of $\,g\,$ is not invertible, e.g. $ \: x = 2x\:q + r\:$ has no solution for $ \:r\in \mathbb Z,\ q\in \mathbb Z[x],\:$ since evaluating at $ \:x=0\:$ $\Rightarrow$ $ \:r=0,\:$ evaluating at $ \:x=1\:$ $\Rightarrow$ $\:2\:|\:1\:$ in $\mathbb Z,\,$ contradiction. Notice that the same proof works in any coefficient ring $ \:R\:$ in which $2$ is not invertible. Conversely, if $2$ is invertible in $ \:R,$ say $ \:2u = 1\:$ for $ \:u\in R,\:$ then division is possible: $ \: x = 2x\cdot u + 0.$
However, we can generalize the division algorithm to the non-monic case as follows.
Theorem (nonmonic Polynomial Division Algorithm) $\ $ Let $\,0\neq F,G\in A[x]\,$ be polynomials over a commutative ring $A,$ with $\,a\,$ = lead coef of $\,F,\,$ and $\, i \ge \max\{0,\,1+\deg G-\deg F\}.\,$ Then
$\qquad\qquad \phantom{1^{1^{1^{1^{1^{1}}}}}}a^{i} G\, =\, Q F + R\ \ {\rm for\ some}\ \ Q,R\in A[x],\ \deg R < \deg F$
Proof $\ $ Hint: use induction on $\,\deg G.\,$ See this answer for a full proof.