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$.