How to add a new parent to child

Hi,
I have many objects in a scene. I want to create a parent object for each of these objects. Can someone please tell me if this is possible? I don’t find an approach.

Right click in the scene hierarchy, make a new empty GameObject, then highlight all of the other objects and click and drag them onto the first, which reparents them to it.

If you mean in code, the function is in the Transform component- Transform.SetParent().