Everything you need to engineer such a system can be found using the below tutorial. Essentialy you will need a ray, a collision object and a script.
When the app runs set it to capture the mouse. By moving the mouse you point the ray in the scene (adapt the camera rotate code in the tutorial to achive this) Then when the ray collides with the cube (see the part about making a button) and the corosponding mouse or keyboard input is used (Input is shown in the beginning of the character movment section) you can then enable the cube to move along the desired axis as the mouse moves.
https://github.com/gokudomatic/godot/blob/master/demos/3d/kinematic_fps/documentation/Documentation.pdf