Mass is easy to represent as simply [M]
Volume is a quantity that exists only within 3 spatial dimensions. We'll need to take the cube of [L], which gives volume a dimension of [L]³
Density is mass divided by volume, therefore divide [M] by [L]³
The dimension of density is [M]/[L]³ or [M][L]⁻³