MgSO4
This is formula of a "molecule" of an ionic compound, just count the atoms.
Technically there is no such thing as a "molecule" of an ionic compound (unless we are talking about exotic conditions), but you can think of "formula unit" as another name of a molecule.