Some medicines come in blister packs, so those might be able to be used by someone else.
Yes, I just saw something on the news about a machine that can analyze pills, while still in the bottle to make sure they are what they say they are. It’s designed to check for conterfeit pills, but I’m sure it would work for that.