There is some truth to the point that the PU is far away from the rattling frets, and therefore doesn't pick that noise up as much. However, the strings do transmit the rattling's transients over their entire length. This is particularly obvious when you're playing with a piëzo pickup into an acoustic-amp: the piëzo bridge is even further away from the frets than a normal magnetic PU, but still transmits quite a lot of rattle.
The main reason why the rattle is so much more pronounced when playing unplugged than plugged is that there's in both cases filtering going on:
- An electric bass is a bad acoustic transmitter, in particular in the range of the fundamentals of the actual notes you're playing. That's because it doesn't have much resonating volume. However, the fretboard has enough area to transmit high frequencies to the air relatively efficiently. So we can say, playing unplugged means your signal comes through a high-pass filter†. It so happens that the rattle consists almost only of high frequencies, whereas the normal string vibration has very little of those. So, when playing unplugged you hear the rattle well and over only a very quiet reference signal level.
- Magnetic PUs are excellent at transmitting low frequencies to the amp, and if it's a bass amp it should also be good at transmitting those to the air. But most bass PUs have pretty high inductance, and together with the capacitance of the cable (this is assuming a passive bass) that forms an RLC low-pass filter, i.e. the opposite of what you get acoustically. Hence, you'll have a loud low-frequency signal level, but much of the rattley high frequencies filtered away. Moreover, bass amps (especially tube amps) aren't completely linear, they add in some high frequencies of their own through overdrive. This results in psychoacoustic masking, and you may not be able to notice the rattle at all anymore – it's still there, just it stands our much much less then when playing unplugged.
However, the remaining rattle can actually be really useful musically. Active basses can bring this out much better than passive ones, because there's no inevitable filtering by PU+cable. The most extreme use is the slap style, which is all about letting the strings hit the frets real hard; when you do this unplugged you'll hear almost only the percussive clacking noise, and even with a passive bass the effect is still obvious. But at least for me, I think a bit of rattle is also important part of my normal plucking sound, it's quite helpful to bring dynamics out and make your lines audible without needing to crank up higher EQ frequencies (which can easily become annoying).
†Incidentally, with a piëzo PU you'll often also get a high-pass filtering effect, because its impedance is capacitive rather than inductive. That's the main reason why piëzos are often perceived to sound “more acoustic” than magnetic pickups, though really this isn't a property of the pickup types themselves but of the (often not well-designed) circuits they're used in.