The composition can never be completely determined — the composition of a spherical body cannot be fully discerned from just rotation and translation1. However, we can make reasonable guesses. Basically, we can calculate its total mass and moment of inertia by observing its rotation and revolution. Then, assuming that the density ρ varies radially, we get the following two equations:

$$M = \int \rho \pi r^2dr$$

$$I = \int (\rho \pi r^2dr)r^2$$

These do not completely determine ρ, however with other reasonable assumptions on the composition and the amount of planetary differentiation it can have, we can get a good estimate for ρ.

1. It can be determined if we take a larger gravitational field and pivot it, but this ventures into the Aristotlean "Give me a place to stand on, and I will move the Earth." zone of thought experiments.