There are a few different ways. A simple one is to only dip one side into the liquid, or fold it and dip just the middle.
There are other methods which are used in textile art.
Batik uses wax on areas which are not meant to be exposed to the liquid dye.
The waxed areas stay dry and dye free.
Tie-dying uses rubber bands or string to compress the cloth in certain areas and keep them dry while dipped in dye.