Hello,
The question of how to deal with constraints on manifolds ($g(U) = 0$) comes up from time to time: you can find some pointers in posts on this forum (use the search bar at the top).
For example, the post here may help:
As you will see, there is no "definite" answer to this. But there are reasonable things to try.
Best,
Nicolas