How do I fuse two gameobjects together in code (C#) so they act as one physics body?

The scenario is basically when something collides with the right kind of object and sticks to it, and functionally they should be one object from then on. I know there has to be something I can call in the collision enter method, but I just dont know what.

Parent one object to the other. Rigidbodies have a useful behavior where the colliders of child objects work in conjunction with the parent object collider to act as a single collider (this only works if the child colliders are primitive).

When you parent a rigidbody, make sure to remove the child object’s rigibody as that can lead to some weird behaviors. See Docs

create an empty gameobject, you can make a prefab of an empty object.
Then instantiate that, then addComponent(Rigidbody), then find your two gameobjects and parent them to your empty gameobject containing rigidbody.