Speed of the zener will be important. Keep in mind the STM32's inputs have fast rail clamping diodes, so if you exceed the rail voltage it will dump energy to one of the +V rails. I'm assuming that's the 5V rail, but it could be the 3V rail. If the zener doesn't kick in fast enough, then the STM's +V will dump the energy. This energy on your +V rail will likely skew your analog signals, and perhaps it would do other odd things.
How much heat will it make? Running 12V at 1mA which is clamped by a 5V zener will be 5V * 1mA = 5mW. Is 1mA enough current? Would the diode have good enough heat sinking to keep the temperature down with what ever it's dissipated watts are?
If the zener fails for some reason, you'll destroy the STM32, and who knows what will happen to the outputs if a port is blown. So keep in mind the failure modes. AKA does a failed port cause fuel injectors go to 100%, or does it cause the analog MAP to register as 100%?
Also keep in mind you'll probably need a 4.7V or perhaps lower zener to get 5V protection. I seem to recall that 4.7V is what you get at 10mA, and if you run 1mA, your voltage will be higher, perhaps close to 5V. Keep an eye on the diode's curve. Also keep in mind that curve changes with temperature. So bench top vs hot day of operation will change that curve. You might want to check the datasheet for the specific pin you plan to use. I believe most IO will trigger as a guaranteed digital 1 at like 2.7V. So you probably want a 4.1V zener. AKA if it gets hot and wanders lower you are still OK, and if wanders higher for some reason you still have head room before the STM32's ESD diodes kick in.
See figure 2 at the below. Notice how the voltage changes if you get warm.
I would say you can probably get it to physically work, but you might be a bit weak on failure modes.