We start with the following observation. Let $p$ be prime. Suppose that $p$ divides $AB$ with even exponent. Then if $(A,B)$ is prime to $p$, then $p$ divides exactly one of $A$ or $B$, and hence it also divides $A$ and $B$ with even
exponent.
It follows that if $AB$ is the sum of two squares and $(A,B) = 1$,
then $A$ and $B$ are the sum of two squares. Slightly more generally, we find:

**Proposition:** if $AB$ is the sum of two squares and $(A,B) = 1$ or $7$,
then either $A$ and $B$ are the sum of two squares or $7A$ and $7B$ are the sum of two squares.

Now let $\displaystyle{A_n:=777 \ldots 7777 = \frac{7}{9} \cdot (10^n - 1)}$.

If $A_n$ is the sum of two squares, then so is $B_n = 9 \cdot A_n = 7(10^n - 1)$.

**Lemma:** The smallest integer $n$ such that $B_n$ is the sum of two squares is odd.

**Proof:** By observation, the smallest such $n$ is $> 2$. Assume that $n = 2m$ with $m > 1$. We shall obtain a contradiction. We write

$$B_{n} = B_{2m} = 7(10^{2m} - 1) = 7(10^{m} - 1)(10^{m} + 1) = B_{m} (10^m +1).$$

Now $(10^m - 1,10^m +1) = 1$, so $(B_m,10^m +1) = 1$ or $7$. It follows from the proposition that $B_m$ or $7 B_m$ is
the sum of two squares. Since $m > 1$, it follows that $7 B_m \equiv 3 \mod 4$ is not the sum of two squares, and so $B_m$ is the sum of two squares. This contradicts the minimality of $n$. $\square$

Hence the smallest $n$ such that $B_n$ is the sum of two squares is odd. However, this contradicts the fact (which you already observed) that if $n \not\equiv 0 \mod 6$ then $B_n$ is exactly divisible by $7$ and so is not the sum of two squares.
Hence $A_n$ can never be the sum of two squares.