A simple loop with a check may work:
_leader = leader _group;
while {count units _group > 0} do {
_newHCcom synchronizeObjectsAdd [_leader];
waitUntil {leader _group != _leader};
_leader = leader _group;
};
Obviously replacing the variables as you see fit. I'm not 100% sure that's what you're after but in theory that should constantly update who the commander is after the last one dies so long as there is someone in his group to take over.
Also, you don't need that huge amount of subordinate adds at the end of your script. Just use this line:
_newHCsub synchronizeObjectsAdd [leader sg1,leader sg2,leader sg3,leader sg4,leader sg5,leader sg6,leader sg7,leader sg8,leader sg9,leader sg10];
Or even:
{_newHCsub synchronizeObjectsAdd [leader _x]} forEach [sg1,sg2,sg3,sg4,sg5,sg6,sg7,sg8,sg9,sg10]