Magic weapons with special powers against a specific foe are classic staples of fantasy RPGs, with dragon slayers and giant slayers the most well-known, but you can create some fun variants with more particular creatures in mind.
Weapon (greatsword), very rare (requires attunement)
This +1 greatsword is inlaid with red copper like licking flames down its blade. While wielding it, you have advantage on all attack rolls against all giants, and you deal an extra 3d6 slashing damage against trolls. A redflame trollblade glows yellow when orcs are within 120 feet, orange when giants are within 120 feet, and bright red when trolls are within 120 feet. A redflame trollblade sends out an empathic call to trolls within 1 mile. They can sense the direction of the blade, and its presence fills them with hatred. Their attitude becomes hostile and each troll is compelled as suggestion (DC 14) to seek out the sword and destroy you. A troll that successfully saves is immune to this effect for 24 hours unless it comes within 120 feet of the sword, in which case it must save again with disadvantage.
Epic Attunement. As an action, you can make a cleaving strike with the redflame trollblade. If this attack hits, apply the same attack roll (and damage, if the attack hits) against all enemies adjacent to that target and within your reach.