This is impossible to do because the total mass and center of mass do not uniquely define a mass distribution $\rho(\mathbf r)$.
The total mass is
$$M=\int\rho(\mathbf r)\text dV$$
the center of mass is
$$\mathbf r_{\text{com}}=\frac{1}{M}\int\mathbf r\rho(\mathbf r)\text dV$$
Since $\rho(\mathbf r)$ is contained within the integrands of these integrals you can't have a unique density function. Integrals do not uniquely determine an integrand. Even more specifically, the center of mass is essentially just a weighted average. If I told you that I have a list of numbers whose average is $10$, would you be able to tell me which numbers I used? You would not be able to without additional information.
A really easy counter-example is just to consider two similar objects of different sizes. For example, a sphere of volume $V$ and a sphere of volume $2V$. If you make the uniform density of the smaller sphere $2\rho$ and the density of the larger sphere $\rho$, then they both have a mass $2\rho V$. Furthermore the center of mass of each sphere is located at the center of the sphere. Therefore, we have two objects with the same mass and same center of mass location, but they have different mass density functions.