To reproduce:
1. Use the below command to give yourself a stone sword with the enchantments tag disabled.
/loot give @s loot {"pools":[{"rolls":1,"entries":[{"type":"minecraft:item","name":"minecraft:stone_sword","functions":[{"function":"minecraft:set_components","components":{"!minecraft:enchantments":{}}}]}]}]}
2. Attempt to rename the stone sword in an anvil.
❌ You cannot rename the stone sword in an anvil, despite the minecraft:custom_name component not being disabled.
Can confirm.