Welcome to the forums @Asmun!
Could you share the code you are using? Also, what version of Godot are you using?
Changing the sprite in code should work using something like this:
var new_texture = preload("res://path_to_texture_here.png")
func _ready():
get_node("sprite").texture = new_texture
But if it is not, then it may be something else is going on and that's causing it not to change.