This would be relatively new. Since the Item Metadata is stored in a different registry from the Item, it used to be OK to have .items files but be able to change the Item metadata from a rule. You could even change the metadata for stuff defined in .items files. Of course the next time the .items file was is loaded the metadata gets reset, but it wasn’t read only.
The same applies to Links. You can (could?) define the Item in a .items file but link the items to Channels through the UI.
There were some discussions in GitHub years ago about changing this behavior, but I argued against that (I thought).
Maybe it’s only the metadata that is in the .items file that is marked read only?
This is definitely something new and not something I like at all.
The error is somewhat odd but the mention of ManagedMetadataProviderImpl implies the error is coming from core.
But there is no reason why one could not and should not be able to define new managed metadata on a read-only Item.
It’s not exactly what you’re asking, but I have a successful setup defining a bunch of items in Javascript and setting all aspects of them including Metadata. I have them set in functions that are called for each room where I want the items, so it’s a bit generic but hopefully you get the idea.
I’m not changing things dynamically so this just runs once per room when I start up openHAB or change the Javascript file, but it seems to work just fine either way.
FWIW I have these functions that change Metadata. I don’t seem to be using them anywhere. I wrote this code a couple years ago and don’t remember why I settled on the replace item function calls, but thought it would be helpful to see some working code examples.