The very simplest possible implementation is to use a single resistor(!) to protect the input pin, as described in this source. The AVR inputs are protected from over/under voltage by internal silicon diodes D1 and D2. The input resistor must be sized such that it will conduct no more than 1 mA when the internal clamping diode, D1, conducts at Vcc+0.5V, or 5.5V in this case. A 22K resistor could work in this case if we use our 24V supply for the sensor. Our current through the clamping diode is calculated by Ohm's Law as (24V - 5.5V)/22K = 0.84 mA.
There is no reason, in this case, to cut so close to the bone though. We do not need particularly high speed detection for this application, so a 100K resistor would be a better choice, and limits diode D1 to 0.19 mA. This gives additional protection for voltage spikes.
This solution works well until the internal diode gets fried by a spike or surge, so it is much better to add redundancy, and use a pair of external Schottky clamping diodes, which have a lower forward voltage drop and will conduct before the internal silicon diodes.
So, my solution, (the one I plan to implement soon on my own Ender 3 Pro*), is from this source article and looks like this:
Where R1, D3, and D4 are my external components as described, and C1 is omitted for simplicity. (If C1 is used, it forms a low-pass RC filter, so you'd need to size it appropriately. If we find that noise or 'bounce' is an issue, we can add C1 easily later.)
In my opinion a single 100K resistor and two Schottky diodes are adequate protection for this circuit, and the 6-36V proximity sensor will work very well on the available 24V supply.
*Based on the first comment to this proposed solution, I recognize the need to look carefully at the failsafe property here. Depending on whether the existing Z endstop is included in the loop, and how Marlin handles this too will determine whether this is a satisfactory solution.
I'll leave my part of the discussion there for now, until I get closer to design and implementation on my own machine.