Similar to this question, does hitting people with tools cause them to not like you? Unlike the other question I have never seen an NPC react but I know I have accidentally swung an axe or hoe in the direction of them before.
You can't hit someone with a tool or a melee weapon. When you swing one of these items, one of the things the game checks is whether your potential target is a monster. Monsters can be whacked; ordinary NPCs (including animals) can't.
(Source: Snooping in the source code with a decompiler)