This forum is really for answering specific questions I cannot write all the code for you but I can give some pointers to try to help.
If you have something like this attached to the camera in a scene as a script;
var DistanceToCharacter = 0
func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
var move = event.position - get_viewport().size * 0.5
if move.length() < DistanceToCharacter:
self.position = vector2(0, 0)
else:
self.position = move.normalized() * (move.length() * DistanceToCharacter) * 0.5
this would allow you to set the camera to follow the mouse. If you then tie the variable DistanceToCharacter to some code which checks how far it is from your sprite it will allow you to control the camera the way you want. Or at least it should, I havent tested this its just how I would program it.