Sure. You'll need two commands for that, though.
Let's say, for this example, that you've s-modded in Resistant Flux Conduits, and now want it gone. The first thing we need to know is what that hullmod's ID is.
list hullmods resistant flux conduits
Running that will tell us that the hullmod ID is "fluxbreakers"; armed with that knowledge, we can remove it:
runcode ((FleetMemberAPI)Global.getSector().getPlayerFleet().getFleetData().getMembersListCopy().get(0)).getVariant().removePermaMod( "fluxbreakers" )
As with my previous examples, this bit of runcode will apply to whatever ship is first in your fleet.
(And as a note: the list command doesn't require the full hullmod name. You could just do a "list hullmods flux", for example, and it'll give you every hullmod with 'flux' in its name or ID. Which is a much smaller list than all hullmods, and easy enough to pick out the one you need from it.)
Edit/Addendum:
When you add an s-mod to a ship and then scuttle the ship, you get a 'refund' in the form of bonus XP, equivalent to whatever bonus XP you didn't get on adding the s-mod (i.e., 25% return on scuttling an s-modded frigate since that gave the other 75% when you added the s-mod, 100% return for a capital ship since that gave no bonus XP on adding it). The game tracks this - if you scuttle a ship that has s-mods you didn't add (for example, maybe you found one of the rare s-modded derelicts that are out there), you get no bonus XP from that.
I don't know where these values are stored (haven't felt a need to look it up), and don't know how it will interact with removing s-mods via code. I mean, obviously the code for removing the s-mod won't give you any bonus XP, but if you remove an s-mod and then scuttle the ship, how much bonus XP do you get from it? I don't know.