Here is another way to do it, but it still doesn't avoid the glitch when getting close to the center:
extends Sprite
func look_at_mouse():
var mouse_pos = get_global_mouse_position()
var line_pos = $Line.global_position
rotation = mouse_pos.angle_to_point(line_pos)
func _process(delta):
look_at_mouse()
The problem is the rotation also changes the relative position of the line, which means it will glitch out as it is constantly spinning so the values are all messed up. The logic only works right if the pivot is at zero (rotating around the point you are using as a pivot). I can look at it more and see if there is a solution but I'm not sure.