There's some truth to it, though the information often gets exaggerated. Plastic can indeed release harmful substances when heated - especially if the bottle is made from polycarbonate (usually a harder plastic). When a car sits in the sun, the temperature inside rises significantly, and under certain conditions, bisphenol A (BPA) and other compounds can leach from the plastic. The risk is higher if the bottle is damaged, old, or has been used several times already.
That said, it's important to understand that a one-time exposure to a small amount of these substances isn't a disaster. The more realistic problem is bacteria: in warm water that's been sitting in a car for a while, bacteria multiply more actively. So the doctor probably meant that - stagnant, heated water becomes less safe than fresh, cold water.
As for whether it's a myth or reality: it's not quite a myth, but it's also not reason to panic. Just don't leave open water in your car for long periods, especially in hot weather, and drink water that hasn't been overheated. If you have a bottle that's been sitting in your car for a while - better to throw it out and use a new one.