Easy lua.
Source edit. Or:
In lua you can make them deals no damage to the player, but they still will targeting that player. There is alternative, make two monsters named 'Dragon'. Dragon1 will be friendly and Dragon2 will be hostile mob. If any players meet Dragon1 on map, it will disappear and on his place will Dragon2 appear. But if player with xxxx item meets Dragon1, it wont disappear. So, for player with item xxxx it will looks like 'Dragons' are ignoring him.