You can use the _draw function of CanvasItem to do this. Use either Node2D or Control, whatever is better in your case.
Here is an example:
extends CanvasItem
var rect = [Rect2(Vector2(50,50),Vector2(200,200)),Rect2(Vector2(150,200),Vector2(200,200))]
var color = [Color(1.0,0.0,0.0),Color(0.0,0.0,1.0)]
func _draw():
for i in range(rect.size()):
draw_rect(rect[i],color[i])
func _ready():
update()
It's also possible to draw some other things like circles, textures and lines.