This is a follow-up of this question.
Let $A$ be a real diagonal $n \times n$ matrix, with rank $\ge n-1$.
Suppose that the eigenvalues (counted with multiplicities) of $A$ are the same as the eigenvalues of $QA$ for some special orthogonal matrix $Q$. Must $Q$ be diagonal?
The condition $\text{rank}(A)\ge n-1$ is necessary: If we allow $\text{rank}(A)< n-1$, then one can take $A$ to be diagonal with the $A_{11}=A_{22}=0$; then the entire $\text{SO}(2) \times \text{Id}_{n-2}$ preserves the eigenvalues.
No, for example $Q$ can be any rotation and $A=\begin{pmatrix}1&0\\0&-1\end{pmatrix}.$
I think this is pretty much the general case: $\mathbb R^n$ splits as a direct sum of some number of copies of the vector spaces $E_a\simeq\mathbb R^1$ and $V_{a,\theta}\simeq\mathbb R^2$ where:
I will just show how you can reduce the problem to analyzing direct sums of certain two-dimensional spaces - this isn't a complete proof of the above characterization.
The important equation is: $$QA=AQ^T\tag{1}$$
This can be seen in two ways:
Working over $\mathbb C$ temporarily, Schur triangulization gives a unitary $U$ and upper triangular $M$ such that $QA=U^*MU.$ Since $M$ and $QA$ are similar, they have the same characteristic polynomial. So the diagonal entries of $M$ are just the eigenvalues of $QA,$ which are the same as the diagonal entries of $A$ by assumption. So $\sum_i |M_{ii}|^2=\sum_i A_{ii}^2=\|A\|_F^2$ (squared Frobenius norm). But $M$ and $A$ have the same Frobenius norm, so $\sum_{ij} |M_{ij}|^2=\sum_i |M_{ii}|^2,$ forcing the off-diagonal entries to all be zero. So $M$ is diagonal, but the diagonal entries are real so it's in fact Hermitian. So $QA$ is Hermitian, giving $QA=(QA)^*=A^*Q^*=AQ^T,$ which is (1).
Since $QA$ and $A$ have the same eigenvalues $\lambda_1,\dots,\lambda_n\in\mathbb R,$ the traces $\operatorname{tr}(A^2)$ and $\operatorname{tr}((QA)^2)$ are both $\sum_i\lambda_i^2.$ Using Cauchy-Schwarz on the Frobenius inner product gives $\operatorname{tr}(QAQA)\leq \|QAQ\|_F\|A\|_F=\|A\|_F^2=\operatorname{tr}(A^2)$ with equality only when $QAQ=A^T=A,$ and multiplying on the right by $Q^T$ gives (1).
Equation (1) is the defining relation of the infinite dihedral group, except that $A$ is not required to be invertible. The representation theory will be similar. Multiplying (1) on the left by $Q^T$ and on the right by $Q$ gives $$Q^TA=AQ\tag{2}.$$
If we have a subspace $U\subseteq V$ invariant under $Q$ and $A,$ then the orthogonal subspace $U^\perp$ is also invariant under $Q$ and $A.$ Indeed $U^\perp$ is automatically invariant under the adjoints $Q^T$ and $A^T=A$ because $\langle Aw,v\rangle=\langle w,Av\rangle=0$ and $\langle Q^Tw,v\rangle=\langle w,Qv\rangle=0,$ and being invariant under $Q$ is the same as being invariant under $Q^T.$ So it makes sense to decompose $V$ into the direct sum of subspaces that are invariant under $Q$ and $A,$ and that cannot be decomposed further i.e. irreducible representations. Though we can't use the eigenvalues condition directly when analyzing these subspaces.
(1) and (2) imply that the matrices $A$ and $Q+Q^T$ commute. Let $v$ be a simultaneous eigenvector of $A$ and $Q+Q^T.$ So $Av=av$ and $(Q+Q^T)v=\lambda v$ for some scalars $a$ and $\lambda.$ Then $\operatorname{span}\{v,Q^Tv\}$ is invariant under $Q$ and $A$ because $Qv=\lambda v-Q^Tv$ and $AQ^Tv=QAv=aQv$ (and we already took care of $Qv$). So irreducible representations have dimension at most two.
To finish a characterization you could analyze these two-dimensional subspaces.