They can tell by how bad it is.
Many years ago, I heard that there was a way to test your oil for engine problems. I don't know how much of a joke this is, but a man took oil from his Volkswagen to the company because they had a contract with his employer. They told him his Volkswagen was fine. I haven't heard anything like this since.
I hate it that those shops come around when my car doesn't need a change. I once held off so long, thinking I'd find a shop, that when I finally did go, without getting a shop, the mechanic said, "Your oil was in really bad shape."
The last time the oil was changed, I just found a coupon online. It sure beats the mystery shop aspect. It was a very good deal at the local dealer. I took the label off the car window before going in a month early. I never like for them to see that it was done elsewhere. Let them think I did it. Years ago, I used to do my own oil changes, but I decided I didn't like to. Everything worked out well and I only paid $49.99 for a synthetic oil change. I'm going to look for coupons from now on.