Let $G$ be a subgroup of $\text{GL}(n, \mathbb{C})$. A polynomial $f \in \mathbb{C}[x_1, \ldots, x_n]$ is $G$-invariant if for any $g \in G$ we have $f(g^{-1}x) = f(x)$, $\forall x \in \mathbb{C}^n$, equivalently, $g(f) = f$.
The group $\text{SO}(n, \mathbb{R})$ is a subgroup of $\text{GL}(n, \mathbb{C})$. For any $\text{SO}(n, \mathbb{R})$-invariant polynomial $f \in \mathbb{C}[x_1, \ldots, x_n]$, does there exist a $\phi \in \mathbb{C}[t]$ where we have$$f(x_1, \ldots, x_n) = \phi\left(\sum_{i = 1}^n x_i^2\right)?$$
Yes. $SO(n, \mathbb{R})$ is transitive on shells, so given any point $(x_1, x_2, \ldots x_n)\in\mathbb{R}^n$, there's an element of $SO(n, \mathbb{R})$ that takes it to $(u, 0, 0, \ldots 0)$. Now we can choose this $u$ to be $\sqrt{x_1^2+x_2^2+\ldots+x_n^2}$. Thus $f$ is just a function in this $u$. But it's a polynomial, so it's a polynomial of the square of this, $x_1^2+\ldots+x_n^2$.
So $f$ is a polynomial that is a function of $x_1^2+x_2^2+\ldots+x_n^2$ whenever each of $x_1, x_2, \ldots x_n$ is real. Can it be other polynomial? No, because any polynomial that is $0$ on $\mathbb{R}^n$ is $0$ everywhere: for any variable used nontrivially, look at its coefficients, determine a point inductively in $\mathbb{R}^{n-1}$ where they are nonzero, and pick a real number for which the resulting polynomial is not zero. So it cannot be $0$ on all of $\mathbb{R}^n$. So $f(x_1, x_2, \ldots x_n)=\phi(x_1^2+x_2^2+\ldots+x_n^2)$ as required.