In the following all variables are assumed to be integers.
It is easy to write a Diophantine equation which has solutions only when $N$ is a square. i.e.
$$N=A^2$$
It's trivial to write a Diophantine equation which has solutions if and only if $N$ is divisible by 4:
$$N = 4A$$
Also it is fairly easy to write a Diophantine which has solutions if and only if $N$ is not divisible by 4:
$$(N-4A-1)(N-4A-2)(N-4A-3)=0$$
But how about a Diophantine equation which has solutions if and only if $N$ is not a square number?
(sum, product and minus only can be used).