It'll work and most likely be safe but it's not the right way to do it.
The shore power has a neutral-ground bond. Since shore power doesn't always exist, the neutral-ground bond doesn't always exist therefore, the inverter needs to have a neutral-ground bond.
If only the hot is switched then...