I would like to add the following description based on Wigner's theorem, as described on page 62 in the book "quantum mechanics a modern development":
Theorem (Wigner). Any mapping of the vector space onto itself that preserves the value of $|\langle\phi \mid \psi\rangle|$ may be implemented by an operator $U$:
$ \begin{aligned} |\psi\rangle \rightarrow\left|\psi^{\prime}\right\rangle &=U|\psi\rangle \\ |\phi\rangle \rightarrow\left|\phi^{\prime}\right\rangle=U|\phi\rangle \end{aligned} $ (3.1)
with $U$ being either unitary (linear) or antiunitary (antilinear).
The transformation of state vectors, of the form (3.1), is accompanied by a transformation $A \rightarrow A^ \prime$ of the operators for observables. It must be such that the transformed observables bear the same relationship to the transformed states as did the original observables to the original states. In particular, if $A\left|\phi_{n}\right\rangle=a_{n}\left|\phi_{n}\right\rangle$, then $A^{\prime}\left|\phi_{n}^{\prime}\right\rangle=a_{n}\left|\phi_{n}^{\prime}\right\rangle$. Substitution of $\left|\phi_{n}^{\prime}\right\rangle=U\left|\phi_{n}\right\rangle$, using (3.1), yields $A^{\prime} U\left|\phi_{n}\right\rangle=a_{n} U\left|\phi_{n}\right\rangle$, and hence $U^{-1} A^{\prime} U\left|\phi_{n}\right\rangle=a_{n}\left|\phi_{n}\right\rangle$. Subtracting this from the original eigenvalue equation yields $\left(A-U^{-1} A^{\prime} U\right)\left|\phi_{n}\right\rangle=0$. Since this equation holds for each member of the complete set $\left\{\left|\phi_{n}\right\rangle\right\}$, it holds for an arbitrary vector, and therefore $\left(A-U^{-1} A^{\prime} U\right)=0$. Thus the desired transformation of operators that accompanies (3.1) is
$A \rightarrow A^{\prime}=U A U^{-1}$. (3.2)