I've made an edit to this question and title.
Consider a unitary matrix $D$ which satisfy the relation $$D^TMD=M$$ where $M$ is a diagonal matrix with non-zero diagonal elements $m_1,m_2,m_3$.
I'm trying to prove that D is diagonal and its elements are $D_{ij}=\pm \delta_{ij}$ provided $m_1\neq m_2\neq m_3$.
Assume $$D=\begin{pmatrix}a & b & c\\ e & f & g\\p & q & r\end{pmatrix}$$ and $$M=\begin{pmatrix}m_1 & 0 & 0\\ 0 & m_2 & 0\\0 & 0 & m_3\end{pmatrix}.$$
Since $D$ is unitary $D^\dagger D=DD^\dagger=I$. Therefore, $$MD=D^*M$$ which gives $$a=a^*,b=b^*\frac{m_2}{m_1}, c=c^*\frac{m_3}{m_1}$$ and so on.
I think, I have exhausted all the conditions on D. But I'm not being able to show that the off-diagonal elements are zero and diagonal elements are $\pm 1$.
It shouldn't particularly matter what the eigenvalues/diagonal entries of $M$ are since $D$ is constrained to be unitary. What this means in particular is that since $D^TD = D^2 = I$, we have that $D$ is its own inverse and therefore has full rank. The unitary and diagonal conditions force all the diagonal entries of $D$ to be $\pm1$. If in general we assume a diagonal entry is of the form $a + bi$ we must have that
$$ (a + bi)^2 \;\; =\;\; (a^2 - b^2) + 2ab i \;\; =\;\; 1 $$
meaning that either $a$ or $b$ are zero but not both. If $b=0$ we simply have $a = \pm 1$. If $a =0$ we then have that $b = \pm i$ and the diagonal entry is $bi = \pm i^2 = \mp 1$.
Actually under further inspection this is simpler (assuming complex entries). Simply having the unitary condition means $D^*D = DD^* = I$, which means that a diagonal entry must satisfy $\overline{d_{ii}} = d_{ii}$ which means the diagonal entries must be real, and $d_{ii}^2 = 1$.