That doesn't make it an NTA though, at best it makes it into an ESH.
Publicly humiliating the cashier because you can't tolerate a couple of minutes of stilted conversation is immature. If you feel that badly about it put in a complaint.
He isn't teaching them a lesson (and that line made my skin crawl) because I don't think a lot of people would actually get it, it sounds like hes dealing with someone who's a bit socially unaware and has been told they have to make small talk as a job requirement and they aren't good at it.
I don't think many people would make the leap to this guy is telling me to keep my nose out of his business, I think most people would think this guy is way too open about his sex life.
Teaching is explaining theres a problem, why its a problem and telling them how they should do it better.
Which is why if he feels this strongly about it he should be talking to the manager, not this.