The sum of two squares theorem can be proved by working in $\Bbb Z[i]$.
By working in $\Bbb Z[\zeta_3]$ instead, where $\zeta_3$ is a third root of unity, one may prove that an integer greater than one can be written in the form $a^2+3b^2$ (or equivalently, in the form $a^2+ab+b^2$, see the comments) if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime $p \equiv 2 \pmod{3}$.
There is a similar statement for every quadratic number field with class number one. This may be proved by using unique factorization in the ring of integers, quadratic reciprocity and the characterization of splitting of primes in quadratic extensions in terms of Legendre symbols.
Here are some more examples:
By working in $\Bbb Z[\sqrt{2}]$, one gets that an integer greater than one can be written in the form $a^2-2b^2$ if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime $p \equiv 3,5 \pmod{8}$.
By working in $\Bbb Z[\sqrt{-2}]$, one gets that an integer greater than one can be written in the form $a^2+2b^2$ if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime $p \equiv 5,7 \pmod{8}$.
By working in $\Bbb Z[\frac{1+\sqrt{-19}}{2}]$, one gets that an integer greater than one can be expressed as $a^2+ab+5b^2$ if and only if its prime decomposition contains no factor of the form $p^k$, where $k$ is odd and $p=2$ or $p\equiv 3,4,8,10,12,13,14,15,18$. Note that the quadratic form here is non-diagonal, because the ring of integers of $\Bbb Q(\sqrt{-19})$ is not $\Bbb Z[\sqrt{-19}]$.
There's another phenomenon that these examples so far haven't covered. If the number field is real quadratic and there is no unit with norm $-1$ in $\mathcal O_K$, then we need to introduce a $\pm$ in the quadratic form to get a correct statement.
For example, in $\Bbb Z[\sqrt{7}]$ one has the fundamental unit $3\sqrt{7}-8$ with norm $1$, and so one gets that that an integer greater than one can be written in the form $\pm(a^2-7b^2)$ if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime $p \equiv 5,11,13,15,17,23 \pmod{28}$.
It is conjectured that there infinitely many real quadratic number fields of class number $1$, so if that conjecture holds, we get infinitely many such theorems. (LMFDB lists 177168 examples)
Here's the general theorem that may be specialized using some Legendre symbol computations (i.e. qudratic reciprocity) to give congruence conditions:
Theorem Let $K=\Bbb Q(\sqrt{D})$ be a quadratic number field with $D$ square-free and suppose that the ring of integers $\mathcal O_K$ has class number $1$. We have six cases:
- $D<0$ and $D \not\equiv 1 \pmod 4$
- $D<0$ and $D\equiv 1 \pmod 8$
- $D<0$ and $D\equiv 5 \pmod 8$
- $D>0$ and $D \not\equiv 1 \pmod 4$
- $D>0$ and $D \equiv 1 \pmod 8$
- $D>0$ and $D \equiv 5 \pmod 8$
For the cases 4-6, we have two subcases each:
a) the fundamental unit of $\mathcal O_K$ has norm $-1$
b) the fundamental unit of $\mathcal O_K$ has norm $1$
We then have the following properties:
- An integer greater than one can be written in the form $a^2-Db^2$ if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime such that $\left(\frac{D}{p}\right)=-1$
- An integer greater than one can be written in the form $a^2+ab+\frac{1-D}{4}b^2$ if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime such that $p=2$ or $\left(\frac{D}{p}\right)=-1$
- An integer greater than one can be written in the form $a^2+ab+\frac{1-D}{4}b^2$ if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime such that $\left(\frac{D}{p}\right)=-1$
- An integer greater than one can be written in the form $a^2-Db^2$ (in subcase a) or in the form $\pm(a^2-Db^2)$ (in subcase b) if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime such that $\left(\frac{D}{p}\right)=-1$
- An integer greater than one can be written in the form $a^2+ab+\frac{1-D}{4}b^2$ (in subcase a) or in the form $\pm(a^2+ab+\frac{1-D}{4}b^2)$ (in subcase b) if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime such that $p=2$ or $\left(\frac{D}{p}\right)=-1$
- An integer greater than one can be written in the form $a^2+ab+\frac{1-D}{4}b^2$ (in subcase a) or in the form $\pm(a^2+ab+\frac{1-D}{4}b^2)$ (in subcase b) if and only if its prime decomposition contains no factor $p^k$ where $k$ is odd and $p$ is a prime such that $\left(\frac{D}{p}\right)=-1$