Assuming you have a reference to the sprite, you can do something like this.
var energy : int :
set(value):
energy = value
if energy >= 10:
sprite.modulate = Color.WHITE
else:
sprite.modulate = Color.BLACK
Color.WHITE is the constant for the default white setting, which just multiplies the pixel color of each pixel's rgba values by 1.0, and Color.BLACK multiplies them all by 0.0 (leaving the alpha at 1.0). So, WHITE will be the normal image, and BLACK will be that image, but blacked out entirely. If this is in a script on the direct parent of your sprite, you could get the reference by doing $Sprite2D (or replace "Sprite2D" with whatever you renamed it to). If not, you'll have to find another way to do it. One possibility is to have a function in a script on your sprite that takes a energy value and sets the sprite's modulate based on it, then have this set method of your energy emit a signal (which you would declare with a parameter like this signal energy_changed(energy), and emit like this energy_changed.emit(energy) from inside the setter for energy (as shown above). Then you can take the if block out of this setter, and put it into that function on your Sprite script, and connect the signal to the function. You can make such a connection in the editor from the Node tab (usually to the right of the inspector tab in that panel), under signals. This works if you have these things each already present in your scene tree. If not, you'll have to figure out how to get this connected in code. One possibility is to add whatever node has the script with energy in it to a group with a group name. Call it whatever you want, but as long as it's the only node in the group with the name you give it, you can get a reference to it using var energy_node = get_tree().get_first_node_in_group("energy group name"), where I just made up names for the example.