You can get the floor normal using
get_floor_normal, then set the rotation of your sprite to be equal to the angle of the floor normal.
Note that you should call
get_floor_normal after calling
move_and_slide(). You can also use the
is_on_floor() method to check if the player is on floor and only get the normal then.
So, the code could look something like this:
func _process(delta: float) -> void:
# Some code for getting the velocity, applying gravity, etc
var normal: Vector2 = get_floor_normal()
$Sprite.rotation = normal.angle()
Depending on your sprite, you might need to apply an offset to the rotation in order to align your it properly with the floor tho.
var offset: float = deg2rad(90)
$Sprite.rotation = normal.angle() + offset
angle() method returns the angle of the vector in radians. You can use
rad2deg() to convert them into each other.
Edit: Formating and spelling errors.