I have been in this situation a hand full of times. Even when I was at the gym working out myself.
I find it depends on how bad the form is and even how the individual looks. If it is obvious they have been working out for a long time I assume they wouldn’t listen to me anyway so they have to be real bad.
Lets say I have been in this situation 5 times. My first step is to talk about the proper form with MY client at a louder voice and say why bad form can hurt you. 2 out of 5 will be listening because my shirt says trainer and they listen for free tips already. Next would be to mimic good form and bad. this will cat attention for maybe a total of 3 out of 5. My next step is to wait for them to finish and have a couple seconds of rest and just go over and say “hey my Name is Marcus and I am a CPT and notices you were working great, if you don’t mind can I show you a way to get more out of this exercise tho?”
People don’t like to hear “your wrong and are going to hurt yourself” Then I offer them some free training time.
Beyond that there is not much more I do. I don’t like to sound know it all so i do my part to correct them and the forget about it.
Hope that helps!