Circuit that can switch between Vcc and High-Z
You're looking for the MOSFET version of an Open collector circuit.
A P channel MOSFET is a great way to go for this. But pick one based on your input signal, load current, and input signal frequency. The MOSFET input capacitance will limit how fast it can turn on. Ids is a rough figure for the maximum current it can handle (with heatsinks, good gate charge, etc.)
And the voltage of your input signal must exceed the &quot;threshold voltage&quot; in order for it to work. Look at the Vgs vs Rds graphs to get a good idea of how well your MOSFET will connect output to ground before you buy. The &quot;on resistance&quot; in the datasheet is usually for a high voltage applied to the gate, which your input signal may not be able to produce.
You may have to do a 2-stage approach if your input signal can't reach Vcc. This is because you have to put Vcc on the gate to turn it off. If your signal is small (e.g. 3.3V), you can put a pullup on the gate to Vcc (10K is fine) and a second, smaller N channel FET to pull the P channel gate to ground. This will invert the output, but allow a  weak signal to control a large output voltage. See schematic for example.



simulate this circuit &ndash; Schematic created using CircuitLab
.