Suppose I have a real $m \times m$ symmetric matrix $A$, and a real $m \times m$ diagonal matrix $D$. I'm interested in finding $\operatorname{tr}(DA)$. Suppose $d$ were a scalar constant, then I know the following holds: $$\operatorname{tr}(dA) = d\cdot \operatorname{tr}(A)$$
In this case, I'm trying to think whether it's possible to pull the diagonal matrix $D$ outside of the trace operation. Since
$$\operatorname{tr}(DA) \neq \sum_{i=1}^m d_{i} \operatorname{tr}(A),$$ where $d_{i}$ is the $i$th element along the diagonal of $D$, I was thinking whether I can modify the equation as follows so that it might hold:
$$\operatorname{tr}(DA) \overset{?}{=} \sum_{i=1}^m d_i \operatorname{tr}(B^TAB)$$
However, I'm not sure what exactly the matrix $B$ should be. Am I on the right track?
Edit: Also, note that $tr(D) = \sum_{i=1}^m d_i > 0$.
No. Take, for example, $m=2$, $D=A=\operatorname{diag}(1,-1)$. Then $DA=I$ so $\operatorname{tr}(DA)=2$. However, $\operatorname{tr} D=0$ so there cannot be any formula of the form $$ \operatorname{tr}(DA)=\operatorname{tr}(D)f(A). $$