Thanks for responding. It turned out we actually already had such a script, and I was able to add the hosts to the group. I’m sure others might find your script useful if you still want to post it, though!
There is a command line interface to the MySQL DB. Using this you should be able to add those hosts to a group. Start with creating that group in the web gui and noting down the ID (which you see in the URL bar of your browser when editing that group).
Knowing this set me in the right direction, I was able to add these hosts with a short perl script, thanks.