There are a number of sensor filters that may help:
https://esphome.io/components/sensor/index.html#filter-out
https://esphome.io/components/sensor/index.html#max
https://esphome.io/components/sensor/index.html#min
https://esphome.io/components/sensor/index.html#lambda
However it would be best if you fixed your electrical issues causing the erroneous reading. I have dozens of DS18B20 sensors. None of them send bad data.
What pull-up resistor are you using?
How long are the cables?
Are they run close to motors or pumps?