Assuming that your Player is facing its z-axis, and you know your Player's and NPC's position, you could calculate the angle like this:
var facing = transform.basis.z
var player_enemy_direction = player_pos.direction_to(npc_pos)
var direction_scalar = player_enemy_direction.dot(facing);
npc_pos are global positions and they are normalized.
Based on the
direction_scalar, you can change your NPC's sprite.
direction_scalar will be a number between
-1 (180°) and
1 (0°) (if your positions are normalized)
It's quite tricky. I would recommend you to check out Godot's Vector math documentation