Somewhere around here there's a thread where I proposed doing that, replacing the switching hall sensor in a brake lever with an analog one out of a hall throttle, using that to control a small PWM circuit that would then toggle the ebrake line.
I havent' pursued it yet mostly due to time, but also because the controller would have to be modified inside, if it is even possible: All of the cotnrollers I have used so far take significant time (up to a whole second!) to respond to the ebrake input, so any PWM would have to be a minimum of pulse length to match the response time of the controller. Any shorter pulse isn't responded to.
So it would only do any good on very long braking stretches, like a long downhill run, and does not have time to do anything at all on short braking for typical stops or traffic slowdowns and the like.
The other issue is that even on the long downhill runs, you will basically get full-strength braking pulses, spaced apart by however long it takes your controller to respond to an input. Each pulse would be as long as the PWM input told it to be, plus whatever the ebrake's response time is (because at least some controllers *also* take time to *release* the brake, as well as to engage it).
So except for some of the controllers being designed around here that may have this type of thing built in by popular demand (like RickyNZ's) or that might have it added easily (Jeremy Harris'), it would not practically work on most of the typical ebike controllers out there, for most of the situations in which it would be desirable (for me, at least).