You can save a scene like this:
var file_path = "res://your_scene.tscn"
var scene = PackedScene.new()
Note that when instancing or removing nodes from this scene, you have to set the owner or it won't get saved.
When instancing a new node:
$new_node.owner = root_node_of_your_scene
When removing a node:
$node_to_remove.owner = null
And make sure you don't override your original scene.