It could be done easier than with ImmediateGeometry:
Make Spatial -> MeshInstance hierarchy. Make this mesh to be a f.i. cylinder with height = 1.0 and then offset it like Y+0.5, that its bottom located at parent Spatial origin.
Then you should point that Spatial to the target like with look_at()
or as a child of weapon and apply scale to that axis according to the target distance like
laser_ray.scale = Vector3(1.0, distance, 1.0)
You may also need a RayCast
to know exact distance and to don't allow your laser to penetrate through rigid objects.