I've seen this done before, and even though I am highly proficient in commands, it seems this is the only thing I can't quite figure out.
When I click on an empty armor stand while my hands are empty, I want it to execute a command on the clicked-on entity. For example, I click on an entity (armor stand, villager, etc.) and lightning is summoned at the entity, or it tags the nearest sheep with a test tag.