Add a script to your spotlight and add this code.
extends SpotLight
var battery_amount = 100
var drain_rate = 2
var on = true
func _process(delta):
if on:
battery_amount -= drain_rate * delta
light_energy = battery_amount / 100
drain_rate
is how fast the battery drains.
You can turn on or of the flashlight by setting the on variable to true or false.