Simply apply jumpForce
as a vector rotated towards the mouse.
velocity += Vector2(jumpForce,0).rotated(get_angle_to(get_global_mouse_position()))
If that doesn't work it may be because the getangleto() is using local coordinates instead, If that's the case use this instead.
velocity += Vector2(jumpForce,0).rotated(get_angle_to(get_local_mouse_position()))
Hope this helps, also remember to tell people what kind of object you're using when it comes to physics whether it's a kinematic, rigid, or custom.