First, look at the following:
$$\frac{\mathbb{Z}[i]}{(n)} \cong \frac{\frac{\mathbb{Z}[X]}{(X^2+1)}}{\frac{(n, X^2+1)}{(X^2+1)}} \cong \frac{\mathbb{Z}[X]}{(n, X^2+1)} \cong \frac{\mathbb{Z}/n\mathbb{Z}[X]}{(X^2+1)}. $$
Now this last ring is a field if and only if $n$ is a prime $n$ and $X^2+1$ is irreducible over $\mathbb{Z}/n\mathbb{Z}$. This means $\mathbb{Z}[i]/(n)$ is a field if and only if $n$ is prime and $-1$ is not a square in $\mathbb{Z}/n\mathbb{Z}$. So we need to show that if $n$ is prime,$-1$ is a square in $\mathbb{F}_n$ if and only if $n$ is a sum of squares.
Let $p$ be a prime number. Suppose $p$ is a sum of squares, say $p = a^2+b^2$. Then $b$ is not a multiple of $p$, so it has an inverse in $\mathbb{F_p}$. Then, in $\mathbb{F}_p$, we have
$$(ab^{-1})^2=a^2b^{-2}=-b^2b^{-2}=-1,$$
so $-1$ is a square in $\mathbb{F}_p$.
Now suppose $-1$ is a square in $\mathbb{F}_p$.
Then the map $\varphi: \mathbb{Z}[i] \rightarrow \mathbb{F}_p$ given by $$a+bi \mapsto a+bx$$ where $x^2=-1$ in $\mathbb{F}_p$ is a surjective ringhomomorphism. Because $\mathbb{Z}[i]$ is a PID, there is some $z \in \mathbb{Z}[i]$ such that $\ker \varphi = (z)$. Let $N$ be the norm on $\mathbb{Z}[i]$. Now $p \in (z)$, so there is some $u \in \mathbb{Z}[i]$ such that $p=uz$. Now $N(p)=N(u)N(z)$. If $N(z)=p$, we are done, because there are $a, b$ such that $z=a+bi$, so $a^2+b^2=p$. So suppose $N(z)=1$, then $z$ is a unit, so $(z)=\mathbb{Z}[i]$, contradicting the isomorphism induced by $\varphi$:
$$\frac{\mathbb{Z}[i]}{(z)} \cong \mathbb{F}_p.$$
Suppose $N(z) = p^2$. Then $u$ is a unit, so $(z)=(p)$. However, $\mathbb{Z}[i]/(p)$ contains more than $p$ elements, namely $\overline{i}, \overline{0}, ..., \overline{p-1}$ are all distinct. So the result follows.