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:
A maximal ideal $M$ of ${\mathbb Z}[X,Y]$ is the kernel of a map to a field $k$.
Any field of characteristic zero contains ${\mathbb Q}$ and hence is not finitely generated as a ${\mathbb Z}$-algebra.
Therefore the field $k$ has finite characteristic $p$; therefore $M$ contains $p$.
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))$.
We can lift $\overline{f}$ and $\overline{g}$ to polynomials $f,g\in M$.
It is easy to check that $p,f,g$ generate $M$.
Because ${\overline f}(X,Y)={\overline f}(X,0)$, it follows that $f(X,Y)-f(X,0)$ maps to zero mod $p$.
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.