We use coded value domains for many feature layers. We can modify with an administrator login to ArcGIS Pro or by updating the Hosted Feature Service in ArcGIS online. Is there a way to update the definitions through the Javascript API?
I believe you could this via the REST API.
To edit a layer within a feature service: ArcGIS REST API
The thing to note here is that these kinds of calls allow you to redefine everything about a feature service/layer within a feature service, so it's easy to mess something up. I'm not sure what domain JSON looks like exactly, but you should be able to get JSON for a feature layer, edit the domains on it, and post it using the above call.
edit- I should say that I don't believe there's a JS API wrapper around that REST call, but you can use esri/Request to make the request.