tl;dr: Since Youtube reencodes all videos regardless of the upload format, it really isn't that important. Just export your video with a high bitrate to preserve quality. Also see my answer heremy answer here regarding quality loss caused by Youtube.
Long answer: Each reencoding of a video to a compressed format lowers the quality. Usually, that means you'll lose quality at two points: When you export the edited video from your editing software and when you upload the exported video to Youtube, at which point it is reencoded to a highly compressed, streaming-compatible format. You have no control over that second step, so what you can do to achieve the maximum quality possible is make sure you lose as little quality as possible during the first encoding.
In theory, that would mean export to a perceptually (even though technically not) uncompressed format like Apple ProRes or DNxHD as you suggested. However, unfortunately, Youtube doesn't support those formats, so you'll have to use a compressed format. To minimize quality loss, set a high bitrate in your export settings (assuming rendering and upload time aren't an issue. If they are, you'll have to find some middle ground; exporting with a bitrate that is higher than the bitrate of the source material won't yield any more quality, so that is as high as I would go). If you do that, it doesn't really matter which codec you use, both are highly efficient regarding file-size/quality ratio (VP9 probably a bit more so, but that's more important when you're dealing with low bitrates). Youtube recommends H264, so that's what I would use. However, the best advice I can give you is to try out both, i.e. export the same video as both H264 and VP9 with identical bitrates/other settings, upload both to youtube and check which one looks better to you.