Here is the pin out on a normal ATX Power supply:

Description Wire color Pin number Pin number Wire color Description
+3.3 volts Orange 1 13 Orange +3.3 volts
+3.3 volts Orange 2 14 Blue -12 volts
Ground Black 3 15 Black Ground
+5 volts Red 4 16 Green PS_ON#
Ground Black 5 17 Black Ground
+5 volts Red 6 18 Black Ground
Ground Black 7 19 Black Ground
PWR_OK Gray 8 20 White -5 volts (optional)
VSB +5 volts Purple 9 21 Red +5 volts
+12 volts Yellow 10 22 Red +5 volts
+12 volts Yellow 11 23 Red +5 volts
+3.3 volts Orange 12 24 Black Ground

Here is the Pin out of the HP EliteDesk 800 G2 P1 connector:

Description Wire color Pin number Pin number Wire color Description
Ground Black 1 4 Yellow +12 volts
Ground Black 2 5 Yellow +12 volts
-12 volts Blue 3 6 Purple +12 volts standby

Here is the Pin out of the HP EliteDesk 800 G2 P2 connector:
(edit 12-07-21: Pin out has been corrected. Scroll down for more information about this connector)

Description Wire color Pin number
FANCMD White/Red 1
TACH White 2
PS_ON# Green 3
PWR_OK Gray 4
Empty None 5
Empty None 6

Here is the Pin out of the HP EliteDesk 800 P3 connector:

Description Wire color Pin number Pin number Wire color Description
Ground Black 1 3 Brown +12 volts
Ground Black 2 4 Brown +12 volts

Shout out to a reader that caught my pin out mistake on the P2 Connector. It has been corrected! Here are some pictures for clarification on an HP EliteDesk 800:

It is hard to read but above there is a small 6 on the far left of the connector I originally missed which indicates that is pin 6. The arrow would indicate pin 1.

Here is my MB model and the original power supply info on the HP EliteBook 800 G2 (MotherBoard: PESUC0MCY646SI, AS#795206-001 PowerSupply: 5FYZU0CM760879):

 

Here is what the socket looks like on an HP EliteDesk Z240 (MotherBoard: PESRH0LCY583C3 AS#795000-001 PowerSupply: 5ETJN0BM752370):

Update 12-07-2021: This computer has been in a dusty shop environment for two years and so far so good.

Match all the colors of the P1 and P2 cables to the colors on the normal power supply. The purple needs converted from +5v to +12v. I bought this on Amazon to do that.

The White Cable from the P2 connector can be connected to the Gray cable on the CHFAN2 plug to resolve the fan error on boot. (I have not tested this)

Here is some information about the TACH signal:
https://www.petervis.com/electronics%20guides/cpu%20fan%20tacho/cpu%20fan%20tacho.html

The White/Red cable from the P2 connector does not need to be used and can be taped off. This cable controls the fan inside the original PS.

The P3 connector is the same connector as a normal power supply so just use the one on the normal power supply to power the CPU.

Well just now while typing all of the above I got the correct cable I ordered to do this modification and will be using the cable. Hope the info above can be helpful to someone. I ordered this:

https://www.moddiy.com/products/HP-Z240-PSU-Main-Power-24-Pin-to-6-Pin-Adapter-Cable-30cm.html

The only difference I see on their cable is on Connector P2 they put pin 6 to pin 17 on the ATX power supply which is ground.

Here is a picture of the P2 connector:

References:
https://www.moddiy.com/pages/Power-Supply-Connectors-and-Pinouts.html
https://superuser.com/questions/869600/what-is-the-6-pin-power-connector-on-an-hp-prodesk