EDIT: Godot now has a lerp_angle
function.
Zylann's solution doesn't seem to work when there's an offset before the lerping:
func _process(delta):
var to_mouse = $Sprite.global_position - get_global_mouse_position()
var offset = -PI / 2
var rotation_to_mouse = to_mouse.angle() + offset
$Sprite.rotation = lerp_angle($Sprite.rotation, rotation_to_mouse, 0.25)
So this is an alternative which works in that case
adapted from https://gist.github.com/shaunlebron/8832585:
func lerp_angle(from, to, weight):
return from + short_angle_dist(from, to) * weight
func short_angle_dist(from, to):
var max_angle = PI * 2
var difference = fmod(to - from, max_angle)
return fmod(2 * difference, max_angle) - difference