If it is like Flappy Bird, then you can create your flag posts in pairs (just like the tubes), and then make them spawn randomly between certain values.
I don't remember if Godot has a random() method, but it's almost sure it does, just pick a random value for spacing in X and a random height for Y. So you can keep an accumulator for X.
onready var flagPacked = preload("res://assets/flag.tscn")
#######
var flagPrev = Vector2() # Give here a good starting value.
var flag = flagPacked.instance()
var newPos = Vector2(flagPrev.x + rand(5, 9), rand(30, 50)) # This here sets pos based on the previous X value.
##########################
flag.set_pos(newPos)
flagPrev = newPos #Update the previous in each flag spawn.
get_tree().get_root().add_child(flag)