Hi
sanjeet11 ,
Here is the thing. You much understand the meaning of comma +which. It refers to the immediate noun before the comma rather than the subject.
Now, let's talk about your options:
Rats form colonies of approx. 20 animals,
each of which consisting.Rats form colonies of approx. 20 animals,
each of which consist one king.In both these options, which refers to animals because that is the nearest noun. Now it is illogical to say animals consists of something. Hence, both of the above options are incorrect.
Rats form colonies of approx. 20 animals,
each of colony consisting. Here, we are correctly defining what colony consists of. Hence, it is correct.
And yes, it is acting as a modifier.
Does that make sense?