See Nodes and scene instances for godot 4 or godot 3.6.
Here's some examples copied from that page.
Building a new scene
var sprite2d = Sprite2D.new() # Create a new Sprite2D.
add_child(sprite2d) # Add it as a child of this node.
Instantiating a new scene from the project
If you already built and saved a scene but it's not already in the active scene, you can instantiate it.
var scene = preload("res://my_scene.tscn")
var instance = scene.instantiate()