I don't think there's a function just for doing that, but you can use the user datamanager. I was looking at includes/cron/promotion.php which changes usergroups based on the Promotions you have configured. For reasons I don't understand (maybe efficiency), it changes the database directly to update some of the fields, then uses the datamanger to update others. So there might be something there that would be useful.
I haven't tested this, but taking some code from promotions.php, you might be able to do this:
PHP Code:
// $userid must already be set to the user's id. If you have the user's info array
// you can use that in place of $user below
$userdm =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
$user = array('userid' => $userid);
$userdm->set_existing($user);
$userdm->set('usergroupid', X); // X is new primary usergroup id
$userdm->save();
Of course that changes the primary group. If you wanted to add a secondary group instead that would be a bit more complicated.
ETA: You could just use an SQL query to update the usergroupid field in the user table, and that's probably enough as long as the change in group doesn't result in changes to titles or ranks or anything like that.