Further investigation:
I found that the issue is not in the encoding itself (so what I wrote about 8 and 10 bit depths is wrong) but in the multiplexer (I am using MKVToolnix): the file plays fine, but when I add subtitles, audio, etc. and save it as a matroska file, the Codec ID changes.
Later I will check if the newly encoded file plays on the raspberry as well.
Janus (Fabio)
Solved!
Or, at least, I've found a workaround.
As you guys told me, the problem was indeed in the Codec ID.
I tried to remux some files with mkvmerge using the --fourcc 0:HEVC option and now the new files play fine.
I have to remux a lot of files, but at least there's no need to re-encode them.
For those who might face the same issue, I remux the files using the following command line:
mkvmerge.exe --fourcc 0:HEVC --output oldfile.mkv newfile.mkv
Thanks to you all for helping me.
Fabio (Janus)