You can only do this with custom PHP otherwise this is going to be a high security risk. Imagine someone just changes your HTML and inserts a different group id: everyone could just join the group he/she likes.
Instead you can Enhancing a Craft CMS 3 Website with a Custom Module - there is already a default one and insert an event to do this by yourself but you need to be careful. I wouldn't trust user input in that case too much.
Event::on(
Elements::class,
Elements::EVENT_AFTER_SAVE_ELEMENT,
function(ElementEvent $event){
if(\get_class($event->element) === User::class){
$joinSpecialGroup = (bool)Craft::$app->getRequest()->getBodyParam('joinSpecialGroup');
if($joinSpecialGroup === true){
Craft::$app->getUsers()->assignUserToGroups($event->element->id, [4]);
}
}
}
);
Note: I woulnd't call the property joinSpecialGroup
- it is just for demonstration