Unfortunately, Godot does not have simple support for masks. There are two options I know of. You can use a texture and blit_rect() to copy a specific area to another texture. This is fairly fast. You can also blit arbitrary shapes, but without anti-aliasing, so they don't look very good. For rectangles it is fine, though, or maybe some simple shapes if you don't need a soft edge.
The other option is to use a Light2D. These can act as masks for 2D canvas items. This will be the easier thing, as you don't need any special code, and it also supports transparency or fades, so you can get an anti-aliased edge. I would try this first, as it will look better, if you search for light masking you might find some help. The texture blit might be slightly faster, so it could depend on what you are doing, but light masks are more flexible.