Ok, figured by just changing the add_child() to
$Path3D/PathFollow3D.add_child(cube)
that this is assigning the cube to the path and makes it follow it.
Thing I noticed: when I assign a cube via the Editor GUI and the path is in the air, the cube drops down to the floor and follows the path. If I add the cube via code, it does not drop down. Do I have to enable gravity somehow for the code generated cubes?