A remark up front: I am not a specialist on ultrasound. However, I am a Geophysicist and we use more or less the same principle to image the Earth's interior, just a very different frequency range compared to your problem at hand; in exploration seismics typically 5-100Hz compared to frequencies in the Megahertz range for ultrasound imaging.
A transducer emits a pulse into the medium (body). This pulse travels with a certain speed and at each "interface" (which can either be a change of density or a change of velocity) a certain part of the incoming energy gets reflected, and the other part gets transmitted through the interface into the next layer. In seismics, these are normally rock formations; in ultrasound imaging, these are different parts of your body.
The reflection (transmission) coefficient, i.e. the percentage of energy that gets reflected (transmitted) at interfaces, is determined by the acoustic impedance contrast. For pulses hitting an interface at normal incidence, the reflection coefficient is given by
$$R = \frac{z_1-z_0}{z_1+z_0}$$
where z1 is the impedance (density times velocity) in the transmission layer while z0 is the impedance in the incoming/reflection layer. The transmission coefficient is given by
$$T = \frac{2z_0}{z_1+z_0}$$
and obviously $T=1-R$ (conservation of energy; in general, I don't consider absorption here). In ultrasound imaging, as far as I know, a constant velocity is assumed for the entire body and this velocity is roughly around 1500m/s (the speed of sound in water). With this assumption, you can then determine the density contrast of two different parts of the body from the amplitude of the reflected and recorded pulse. We can't make the same constant velocity assumption for the Earth, that's why reflection seismics is a bit more complicated and first of all we have to determine some estimate for the velocity within the Earth. If we assume a constant velocity, the reflection coefficient simply becomes
$$R = \frac{\rho_1-\rho_0}{\rho_1+\rho_0}$$
where rho is the density of the medium on the two sides of the interface.
Now, if we go from a medium with small density to a medium with larger density, rho1 > rho0 and consequently the reflection coefficient R will be greater than zero. On the other hand, if we go from a medium with large density to a medium with a smaller density, rho1 < rho0. This means, the numerator in above formula will be negative, and the reflection coefficient will be negative. What does that mean?
It means, if the transducer emits a positive pulse (i.e. a waveform that goes from a zero amplitude to a positive amplitude first), we will upon return receive another positive pulse if the reflection took place at an interface where the density became larger. If the density became smaller at the interface, we will actually receive a negative pulse back, i.e. a waveform that goes from a zero amplitude to a negative amplitude first). If we display, for
instance, pulses with a positive amplitude in black and pulses with a negative amplitude in white on a grey background, we can distinguish from what kind of density contrast the reflection actually came. Here is an example from the world of seismics: on the left is the impedance contrast, then comes the reflection coefficient (as you can see, positive at the first interface, negative at the second interface), then comes the wavelet (the pulse
emitted by the seismic source), and then the seismic trace that we record (positive amplitudes coloured in blue, negative amplitudes coloured in red).
I hope this answers your question. The explanation is somewhat simplified, there are of course lots of pitfalls and other things to consider in practice (for instance, waves might not hit interfaces at normal incidence - then the behaviour of the reflection and transmission coefficients become much more complicated; there will be frequency-dependent absorption, etc, etc).