If, as per the law, it mandates the company to drop female employees, then I think you should follow the practice to avoid any legal proceedings in the said scenario.
1. If the Female is to Use Her Personal Mode of Transport
She should give in writing that she does not need the company's transportation and would manage on her own. The shift timing should be mentioned so that it is understood that despite odd shift hours, she willingly agrees to use her own means of transport.
For example, if a firm has a female staff member working with her brother or cousin, she might prefer to go back with her husband/fiancée or her brother/cousin rather than relying on the company's transport. Whatever the reason is, it is her personal choice, but the company should not be held liable if the female willingly opts out of the transport service.
2. If on a Particular Day She is Not to Use the Company's Transport
In such a case, the female should also give in writing that for the said day she would not be using the company's transport as she shall be picked up by XYZ. She agrees that in such a case, the company is not liable for her safety as they cannot track her safety.
However, for any mishaps, you can also ask the female to note down the contact number and/or address of the person who is to pick her up, her relation with the said person, and the mode of transport.
Seniors can also suggest some ways in such a scenario when the company has no fault, but if some mishap happens, what should be done.