Content warning: This answer assumes knowledge of Hasse-Minkowski and mild (local) class field theory. The latter could be eliminated with some more explicit computations in local fields. References to all required facts can be found in Milne's notes or Cassels-Frohlich, as well as Serre's a course in arithmetic for the basics of quadratic forms. (Updated to correct the case of $d=2$ but the final answer remains the same.)
Start with the case of finite extensions $K$ of $\mathbf{Q}_p$.
Claim: All elements of $K$ are sums of two squares if and only if $i \in K$. If $p = 2$, all elements of $K$ are sums of three squares if and only if $[K:\mathbf{Q}_2]$ is even.
Proof: If $i \in K$ then
$$n = \left(\frac{n+1}{2}\right)^2 + \left(i \cdot \frac{n-1}{2}\right)^2.$$
If $i \notin K$ and $L = K(i)$ then $L/K$ is cyclic of order two. Thus $K^{\times}/N_{L/K}(L^{\times})$ also has order two by local class field theory. But the norms are percisely the elements which are sums of two squares, so "half" the elements of $K^{\times}$ are not sums of two squares.
Let $D/\mathbf{Q}_2$ denote the unique non-split quaternion algebra. This is just the Hamilton quaternions over $\mathbf{Q}_2$ and corresponds to the Hilbert symbol $(-1,-1)_{\mathbf{Q}_2}$. That is, $D = \mathbf{Q}_2[i,j]$ with $i^2=j^2=-1$ and $ij = -j i$. By local class field theory, $D$ splits over $K$ if and only if $[K:\mathbf{Q}_2]$ is even. If $D$ splits over $K$ then the Hilbert symbol $(-1,-1)_{K}$ is trivial and there exists $x,y \in K$ with
$$-1 = x^2 + y^2.$$
But now
$$n = \left(\frac{n+1}{2}\right)^2 + \left(x \cdot \frac{n-1}{2}\right)^2
+ \left(y \cdot \frac{n-1}{2}\right)^2$$
is the sum of three squares. Conversely, if every element of $K$ is the sum of three squares then $-1 = x^2 + y^2 + z^2$ and the quaternion $1 + xi+ yj+zij \in D_K$ has norm zero, which implies that $D_K$ has zero divisors and thus splits. This completes the proof.
If $F/\mathbf{Q}$ is any global field, then $\alpha \in F$ is a sum of $d$ squares if and only if
$$x^2_1 + x^2_2 + \ldots + x^2_d - \alpha x^2_{d+1} = 0$$
has a non-trivial solution. By Hasse-Minkowski, this can be checked locally at each place.
- If $\alpha \in F$ is totally positive then it has a real solution as soon as $d \ge 1$.
- If $v$ is a finite place of odd residue characteristic then it has a solution as soon as $d \ge 3$ because $x^2_1+x^2_2+x^2_3=0$ already has a non-trivial solution since it is a smooth conic and thus it is isomorphic to $\mathbf{P}^1$ over $F_v$.
- Let $v$ have residue characteristic $2$. There is a non-trivial solution as soon as $d \ge 4$ for any $\alpha$ over a local field. For $d=2$ or $d=3$, we can determine whether it has a solution by the local result above. (By weak approximation if $F_v = K$ and not every element of $K$ is a sum of $d$ squares then not every element of $F$ is a sum of $d$ squares; being a sum of $n$ squares in $K$ is an open condition.)
So the answer for a general number field $F$ is:
- $d = 2$ if and only if the localizations $F_v$ for all $v$ contain a square root of $-1$. But this implies that the only primes in $F$ which can split completely are $1 \bmod 4$ and so by Cebotarev $F$ contains $\mathbf{Q}(i)$. If $i \in F$ then every element is a sum of two squares.
- $d \le 3$ if and only if the localizations $F_v$ for all $v$ of residue characteristic $2$ have even degree over $\mathbf{Q}_2$.
- $d \le 4$.
For example, given a quadratic field $F = \mathbf{Q}(\sqrt{D})$ of discriminant $D$, then $d = 2$ if $D = -4$, and $d \le 3$ if $D \not\equiv 1 \bmod 8$.
For the specific fields $F = \mathbf{Q}(\zeta + \zeta^{-1})$ where $\zeta$ is a primitive root of unity of order $n$, write $n = 2^k m$. The Galois group of $\mathbf{Q}(\zeta)$ is
$$(\mathbf{Z}/2^k \mathbf{Z})^{\times} \oplus (\mathbf{Z}/m \mathbf{Z})^{\times},$$
the Galois group of $F$ is the quotient of this group by $(-1,-1)$. Tthe decomposition group $C$ of $v|2$ in $\mathbf{Q}(\zeta)$ is
$$C:=(\mathbf{Z}/2^k \mathbf{Z})^{\times} \oplus \langle 2 \rangle,$$
and the decomposition group $D$ of $v|2$ in $F$ is $C/C \cap \langle -1,-1 \rangle$. Certainly $i \notin F$ so $d > 2$. Hence $3$ squares are always required for these fields $F$ for any $n$. To see when $d=3$ it suffices to compute whether the decomposition group has even order or not. We find:
If $k=0$ or $k=1$, then the order of $D$ is the order of $2 \bmod n$. Hence $d=3$ when $2$ either has order divisible by $4$, or has order $2r$ with $r$ odd and in addition $2^r \not\equiv -1 \bmod n$.
If $k=2$ and $2$ has even order modulo $n$ then $4 | |D|$ and so $2 | |C|$. If $2$ has odd order modulo $n$ then $(-1,-1)$ does not lie in $C$, and so the quotient $|D|$ still has even order. Thus $d = 3$ in all cases.
If $k \ge 3$ then $4 | |C|$ and the decomposition group of $v|2$ of $F$ always has even order, so $d=3$.
For example, if $n=p > 2$ is prime, then $d=3$ if and only if the multiplicative order of $2 \bmod p$ is divisible by $4$, otherwise $d=4$. The few $n$ for which $d=3$ are $n = 5, 8, 12, 13, \ldots $