Not only happening for nametagged or for piglins or zombiefied piglins. Had an invisible zombie attack me while I was lighting up some mineshafts. Fixed it after quitting and reloading the game. Also have a named zoglin that often goes invisible.
I would say this is not a bug as I believe this works as intended by game design and the developers. I believe this is your wish for it to be changed simply because you don't agree with the naming of the items that Mojang added to the game.
There you go. Thankfully I had a backup from when this happened as I saved and exited the world to make a backup and go and see what the villager was so interested in the nether so I had a backup in case it died or something.
It wasn't that bad this time, but I have a few more mods installed now compared to then that might fix some of the lag, but it's still noticeable. Before everything had lag spikes including me, but this time I didn't have problems, just the world around me.
It could also actually be you lost OP powers. I had this issue once too when I changed name on a server I was co-owner of.