They could be doing this already if they wanted to. I agree they shouldn't have this ability in the first place, but this doesn't change anything.
https://en.wikipedia.org/wiki/SIM_lock#European_Union
It seems sim locking is legal, but unlocking has to be allowed after some time.
I couldn't see anything that would differentiate between a carrier lock by esim vs a sim.
I'm not sure that would happen wouldn't most telcos be interested to allow as many users on the network as possible?
With the above in mind, note that it just so happens that telcos sell mobile devices as well as the service. This means they'll make money on increasing device churn.