In my mind I am thinking you might be able to use a voltage divider circuit that takes constant 5volt and drops it’s down to say 2-3 volts into a analog pin for ADC reading.
The “ground leg” of the divider circuit would be your actual connection to what your testing.
If it’s its grounded pin voltage will be where it’s supposed to be.
ADC value would be lowest.
If it’s open, the pin voltage will rise.
ADC will increment to whatever is left over of the voltage drop of the one active resistor.
If it’s +5 volts the voltage will rise higher than open voltage.
ADC will be receive 5volts minus whatever R1+R2/4 voltage drop.
Never tried that in a circuit but should be pretty easy to test.