well the most simple version would be something like
var mpos
var cam_offset_divider = 8 #this is just my personal preference, it can be whatever you want
func _process(delta):
mpos = get_global_mouse_position() #could be get_global_mouse_position() or get_local_mouse_position, it's really your choice - each behaves in its own way. Just don't do get_viewport().get_mouse_position() because that calls the mouse position in the viewport rather than in the computer
$Camera2D.offset = mpos / cam_offset_divider