Suppose a random positive definite matrix $A\in\mathbb{R}^{n\times n}$ has density function (with respect to the lebesgue measure on $\mathbb{R}^{n(n+1)/2}$) $f(A)=g(\lambda_1(A),...,\lambda_n(A))$ where $g$ is a function invariant under permutation of coordinates and $\lambda_1(A),...,\lambda_n(A)>0$ are eigenvalues of $A$, i.e. the density of $A$ only depends on its spectrum. Examples include Wishart distribution (with identity covariance), matrix beta distribution, etc.

Now, we construct another random matrix in the following way: first generate a diagonal matrix $\Lambda$ such that the joint distribution of the diagonal elements is the same as the joint distribution of the eigenvalues of $A$; second we generate an orthogonal matrix $P\in O(n)$ uniformly and INDEPENDENT of $\Lambda$; then we set $B=P\Lambda P^T$.

Now my question is that is the distribution of $B$ the same as the distribution of $A$? If it is true, how do we prove it? It seems obvious but I do not know how to rigorously justify it.

Update: Thank @Iosif Pinelis for giving an counter example! A further question is that, do the diagonal elements of $B$ have the same distribution as $A$'s diagonal elements?