Attacking a wandering trader near a village with an iron golem will not anger the golem, despite the trader itself being a villager-like mob. I have tested this multiple times by attacking/killing wandering traders near a naturally-spawned golem.
How to reproduce
Get a wandering trader spawn egg (stack of 64)
Attack the wandering trader
Notice the iron golem is not doing anything to defend the wandering trader from the player.
Wandering Traders are villager-like, but not a part of the village.