The FCP library needs to be wide gamut. The project color space should be Wide Gamut HDR - Rec. 2020 HLG.
Grade it with those settings in place. How it's seen during local playback in Quicktime will depend on your physical monitor and the MacOS color profile for that monitor.
For the XDR Pro display, Apple Studio display, and all recent MacBook Pros with Liquid Retina or similar displays, in MacOS System Settings>Displays>Preset, select the one that says something like Apple Display P3-600 nits or Apple XDR Display (P3-1600 nits). If it's an older display, it might only say "Color LCD", etc, in which case it won't look as good.
When you export, as a first attempt use the built-in FCP preset File>Share>Export File>Settings, Format: Computer, Video Codec: HEVC (10-bit, HLG, Dolby Vision 8.4), Resolution: (4k or as preferred). Color Space should automatically show Wide Gamut - Rec. 2020 HLG.
Export that, upload to Youtube, wait for it to fully process -- depending on various factors this could take a while. Then stream that video from your Mac. On either Safari or Firefox it should normally show a little red "HDR" tag over the gear icon at bottom right of the playback window.
However I just tested it from two different machines, and Youtube is not working right today with user-uploaded Dolby Vision HDR HLG material (at least from desktop Safari 18.0). Or maybe the Content Distribution Network (CDN) that I connect to isn't working. I have seen this several times before. Vimeo is much more reliable at HDR playback than Youtube.
You can right-click on the Youtube playback window from a desktop browser and select "Stats for Nerds." If it says "Color bt709 / bt709", then Youtube is not properly identifying the Rec. 2020 HLG metadata, or else when the client machine handshakes it doesn't like something about your client config. It should say "Color arib-std-b67 (HLG) / bt2020."
I tested some Rec.2020 HLG Dolby Vision clips I had previously uploaded to Youtube and which worked fine before. Today they are not working (using desktop Safari 18.0). Today the same clips on Vimeo work fine and display in Safari as HLG HDR.
Some other commercial HLG HDR test files work OK on Youtube. There is something messed up on the Youtube's servers right now, or it's some incompatibility with Safari. I got it to work a few times using Firefox 130.0.1, but it wasn't reliable and tended to fall back to Rec.709 streaming playback.
This is an example of how HDR distribution is still quite immature and unreliable. It's not practical to have to tell your viewing audience to try specific browsers, look at Youtube debug info, etc.