This doesn't work because this if/elif/else statement you have here:
if Input.is_action_pressed("ui_right"):
...
elif Input.is_action_pressed("ui_left"):
...
else:
...
will always call $Sprite.play (since you have an else statement).
That means when you are in the air, you are calling $Sprite.play("jump") but then also calling "walk" or "idle" on the very next frame. So your AnimatedSprite is going to be constantly switching back and forth between two animations, which is why it freezes up like that.
To fix this, you could just put the "jump" call at the top, like so:
if not_is_on_floor():
Sprite.play("jump")
elif Input.is_action_pressed("ui_right"):
...
// and so on
Hope this helps.