Legally, I'd be surprised if slapping a car without doing damage was a problem; I can't imagine why it would be.
Morally, if a driver is texting and unaware of their environment, slapping their car to let them know you are there is certainly permissible. Heck, you're helping them to realize the reckless disregard with which they are endangering others; I'd even call it admirable. We might question whether it is OK to not slap the car.