I am not sure if your city has this law, but here if a dog is locked in a hot car and appears to be in distress, you have every legal right to smash the window and help the dog.