I am trying to generate a positive definite matrix $\mathbf{M} \in \mathbb{R}^{k \times k}$ with diagonal entries equal to 1. For this, I am first sampling $\mathbf{W} \in \mathbb{R}^{k \times n}$, then putting $\mathbf{M}' = \mathbf{W}\mathbf{W}^T$. Let $\mathbf{D}$ be the diagonal entries of $\mathbf{M}'$, then $\mathbf{M} = \mathbf{D}^{-0.5}\mathbf{W}\mathbf{W}^T(\mathbf{D}^{-0.5})^T$. This will give a positive definite matrix with diagonal entries 1. But is there a way to generate desired matrix by using $\mathbf{M} = \mathbf{W}\mathbf{D}\mathbf{W}^T$ formula for some $\mathbf{D}$?
Edit 1: For a fixed $\mathbf{W}$ matrix, $\mathbf{D}$ needs to be sampled in such a way that $\mathbf{M} = \mathbf{W}\mathbf{D}\mathbf{W}^T$