Setting a value for sensor by using service call

is there a way to set a sensor’s value by automation/script? I’m using a sensor for a 3D Printer bed temperature, but if I turn the printer off, the last value is just stuck. when this happens i want to set it to 0 degrees