Well, since nobody told me that was completely stupid, I’ve gone and tested this rails command on a little used instance.
And it seems to work (so far)!
Use at your own risk and backup first
To add an email-in address
Group.where(name: "=groups.name=").update(incoming_email: "=groups.name=@=domain=")
To remove an email-in address
Group.where(name: "=groups.name=").update(incoming_email: NIL)