Here's how you can do that.
All you have to do here is use the fact that density is defined as mass per unit of volume.
In essence, the density of a substance tells you the mass of exactly one unit of volume of said substance. This means that you can find the density of a substance by diving the mass of a given sample by the volume it occupies
#color(blue)(ul(color(black)(rho = m/V)))#
#rho#is the density of the substance
#m#is the mass of the sample
#V#is the volume it occupies
In order to find the mass of a sample, rearrange the above equation to isolate
#rho = m/V implies m = rho * V#
Now, let's say that a substance has a density equal to
You can say that the mass of this sample is equal to
#m = x color(white)(.)"g" color(red)(cancel(color(black)("mL"^(-1)))) * y color(red)(cancel(color(black)("mL")))#
#m = (x * y) " g"#