Well I havent implemented the code below but according to the documentation ( see here https://docs.godotengine.org/en/stable/tutorials/viewports/viewports.html ) this should work,
Var Width_Set = 0
var Height_Set = 0
viewport.set_size_override(true, Vector2(Width_Set, Height_Set)) # Custom size for 2D.
viewport.set_size_override_stretch(true) # Enable stretch for custom size.
Tie the WidthSet and HeightSet variables into some user inputs and you should be able to set the size. If you check the website I directed too though it should give you more info.