You'll need to import the corresponding Java classes, create your region of interest, create an object to display, and then add the object.
import qupath.lib.objects.*
import qupath.lib.roi.*
// Any vertices
def x = [100, 200, 300] as float[]
def y = [150, 350, 250] as float[]
// Create object
def roi = new PolygonROI(x, y, -1, 0, 0)
def pathObject = new PathAnnotationObject(roi)
// Add object to hierarchy
addObject(pathObject)