Hi @shankar431 ,
Yes you may use the guide that is originally from the Microsoft blogs over here:
SCOM Task to Add or Remove Management Groups on Agents
https://techcommunity.microsoft.com/t5/core-infrastructure-and-security/scom-task-to-add-or-remove-management-groups-on-agents/ba-p/365819
I would suggest you to also check out Kevin's guide over here:
How to multihome a large number of agents in SCOM
https://kevinholman.com/2018/06/12/how-to-multihome-a-large-number-of-agents-in-scom
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Best regards,
Leon