Write $f(x) = a_0 + a_1x + a_2 x^2 + \cdots + a_nx^n$. Now let $\pi : \mathbb Z[x] \to \mathbb Z[x] / \langle f\rangle$ be the projection (ring) homomorphism $\pi(p) = p + \langle f\rangle$, so that we want to prove
$$f(\varphi(\pi(x))) = 0.$$
This is quite simple, by using the ring homomorphism properties
$$\varphi(\pi(p + q)) = \varphi(\pi(p)) + \varphi(\pi(q))$$
$$\varphi(\pi(pq)) = \varphi(\pi(p))\varphi(\pi(q))$$
$$\varphi(\pi(1_{\mathbb Z[x]})) = 1_R$$
for any $p, q \in \mathbb Z[x]$. Note that this last property, along with the additivity property, gives us (by induction) that $$\varphi(\pi(n)) = \varphi(\pi(n \cdot 1_{\mathbb Z[x]})) = n \cdot \varphi(\pi(1_{\mathbb Z[x]})) = n \cdot 1_R = n,$$ where in any ring $R$ we implicitly write $1 = 1_R$, $2 = 1_R + 1_R$, $3 = 1_R + 1_R + 1_R$, $-1 = -1_R$, etc.
Now we have
$$\begin{align*}
f(\varphi(\pi(x)) &= a_0 + a_1 \varphi(\pi(x)) + a_2 \varphi(\pi(x))^2 + \cdots + a_n \varphi(\pi(x))^n \\
&= \varphi(\pi(a_0)) + \varphi(\pi(a_1))\varphi(\pi(x)) + \varphi(\pi(a_2))\varphi(\pi(x^2)) + \cdots + \varphi(\pi(a_n))\varphi(\pi(x^n)) \\
&= \varphi(\pi(a_0 + a_1 x + a_2 x^2 + \cdots + a_nx^n)) \\
&= \varphi(\pi(f)) \\
&= \varphi(0_{\mathbb Z[x]/\langle f\rangle}) \\
&= 0_R.
\end{align*}$$