What does your gym contract specify regarding onsite training by non-personnel?
If you don’t have anything in your membership contract, you might have a problem enforcing this. You could post a policy or a rule change, perhaps.
As Karin mentioned, trainers have to have some way to attract clients, so they are visible somewhere. If you use a scan-in system at your club, you can identify that person and search for them on social media and professional fitness sites. If they are listed as a traveling trainer for hire, then you can ask them to cease operations in your facility.
Keep in mind, though, that sometimes trainers need to work out. I’ve purchased a membership at a facility 5 miles away from where I work so that I can have some peace and quiet while I exercise. If I work out with a friend there, I’m really just working out with a friend, even though I might know more than they do about fitness.