Well, not quite, because that analogy misses ten orders of magnitude of density difference. That just hurts my brain.
Magnetars are a whole other level of eldritch madness. The energy density of their magnetic fields is ten thousand times the density of lead.
Let that sink in for a minute.
The vacuum around a magnetar contains so much energy in the magnetic field alone that thanks to the E=mc² conversion ratio between energy and mass it has a "mass density" that is the direct equivalent to every single atomic bomb on the planet blowing up all at once and the released energy of all of that getting packed into a cubic centimeter.
https://www.britannica.com/science/pulsar
https://en.m.wikipedia.org/wiki/Magnetar#Description
They are both forms of neutron stars, which average around 20km but are the densest objects known to man. Fun fact, one sugar cube of their material would weigh about as much as a mountain (https://imagine.gsfc.nasa.gov/science/objects/neutron_stars1...).
Only in the sense that black holes don't have finite densities.