I have got the answer from user priivt8 in this post in macrumors. First one needs a late version ffmpeg that supports high bit-depth HEVC encoding, like v3.4.1 here.
Then this is the command:
ffmpeg -i <infile> \
-c:a copy \
-c:v libx265 \
-tag:v hvc1 \
-crf 22 \
-pix_fmt yuv420p10le \
-x265-params "colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc" \
"-i <infile>" <infile> must be replace with the full file name of the video in input
"\-c:a copy" copies the audio
"-c:v libx265" tells ffmpeg to convert to HEVC
"-tag:v hvc1" seems mandatory for Apple devices using quickTime and the like
"-crf 22" is the compression. Lower the value, better the picture and higher the size
"-pix_fmt yuv420p10le" for YCrCB 4:2:0 10-bits HDR
"-x265-params" are the HEVC parameters for color range etc
"<outfile>.mkv" is the file in output. Replace <outfile> with the name you like. The extensions (.mkv) tells ffmpeg to which container convert the video.
I converted it to a mkv file, so there won't be issues adding any audio from the original YouTube video. one may use ".m4v" for videos recognised by Apple devices.
The converted video now plays fine, with HDR BT.2020 in both Apple TV 4K (using Infuse Pro) and Sony's Video in my Bravia with Android TV 7.0.
One may add to ffmpeg the option
To reduce the frame rate from 60fps to 30fps (so it can be played by iTunes in the Apple TV 4K).