I am just putting a long possible comment here. The following has many reformulations; the idea is to give a condition for which the two matrices $A$ and $M$ in the OP question are congruent by a unitary diagonal matrix. 
Let $A=[x_{i,j}] $ be an $n\times n$ complex hermitian matrix. Among the entries $x_{i,j}$ with $j>i$: If for every column ($2\le j\le  n$) or every line ($1\le i \le n-1$)  there is at most one non zero entry $x_l$ with $l=1,\ldots, k$ and $k\le n-1$, then the hermitian matrix $M=[y_{i,j}]=\begin{cases}z_lx_{i,j} &\text{ for }x_{i,j}=x_l, l=1,\ldots,k;|z_l|=1\\x_{i,j}& \text{ for } j\ge i \text{ and }x_{i,j}\neq x_l, l=1,\ldots,k\end{cases}$ is unitarily congruent to $A$ $(M=U^*AU)$ by a diagonal matrix with diagonal entries $\subset\{1,z_1,\ldots,z_k\}$. The proof is a bit direct. I let you figure the relation with the original question.