I guess you mean giving it some kind of randomness during time. Well, thats a matter of how you want the IA to be for your game. A pretty basic approach could be adding a Timer node, setting a few seconds and calling a method to randomize the direction on the timeout signal.
High level:
extends CharacterBody2D
var _direction: Vector2
@onready var timer = $Timer
func _ready():
timer.connect("timeout", _on_timer_timeout)
func _on_timer_timeout():
_direction = Vector2().normalized() # Your random direction generator