Is it possible to calibrate a pwm pump on logarithmic or even linear scale with templates?

I would like to have a 12v/24v pump that I could change the PWM using an input number/slider from about 125-255. The active range for the pumps.
So, If I calibrate the pump for Low, Med, High (125, 190, 255) (50, 75, 100 mL) for 25 seconds (input slider). Calibrated Low, 2mL/sec, med 3mL/sec, High 4mL/sec. Is it possible to to use the value template to build a linear or logarithmic scale that is calibrated? So that if the PWM is changed to 223 it would output roughly 87.5mL, 3.5mL/sec or so? Or if the pump is needed to slow down PWM 158 it would about roughly 62.5mL, 2.5ml/sec?
It might need more calibration points?
I could build it to just have set PWM points based off input_boolean high, med, or low. Which would basically be just using 3 entities for separate calibrations and turning one on would turn the others off. But, this limits the speeds to 3 set points instead of a variable PWM slider.
Anyone have an idea of how I can accomplish this? or if it’s even possible in HA templates?

What integration ar eyou using for this pump at the moment?

I have the pump currently on ESPHome using 8266 based mosfet controller.

Are you using peristaltic pumps? I’m working on a project to automatically dose my stock tanks. I made on a few years ago using relays but it was unreliable. Now I have l298 drivers controlling the pumps, but I’m not sure how to setup everything for calibration