Better yet, you can replace $f(x,y)$ with $f(x)$. See the answer to this question.
Edited to add: At Martin Brandenburg's request, I'm expanding this to add the details I thought were too obvious to mention:
1) A maximal ideal $M$ of ${\mathbb Z}[X,Y]$ is the kernel of a map to a field $k$.
2) Any field of characteristic zero contains ${\mathbb Q}$ and hence is not finitely generated as a ${\mathbb Z}$-algebra.
3) Therefore the field $k$ has finite characteristic $p$; therefore $M$ contains $p$.
4) Now $M/(p)$ is a maximal ideal in $({\mathbb Z}/p{\mathbb Z})[X,Y]$ and therefore (by the answer to the question linked above) has the form $(\overline{f}(X),\overline{g}(X,Y))$.
5) We can lift $\overline{f}$ and $\overline{g}$ to polynomials $f,g\in M$.
6) It is easy to check that $p,f,g$ generate $M$.
7) Because ${\overline f}(X,Y)={\overline f}(X,0)$, it follows that $f(X,Y)-f(X,0)$ maps to zero mod $p$.
8) By 7) and 6), $(p,f(X,0),g(X,Y))=(p,f(X,Y),g(X,Y))=M$, so that $M$ has generators of the advertised form.
Edited to add further: As Yves Cornulier points out in comments, step 2) above is less trivial than both I and Will Sawin made it out to be. The key additional point is that a field $k$ finitely generated over ${\mathbb Z}$ must have finite characteristic because --- by the generalized Nullstellensatz --- the unique closed point in $Spec(k)$ must map to a closed point in $Spec({\mathbb Z})$.