I got the same issue as your post.
I am trying to create an empty metadata by "CGImageMetaDataSetValueWithPath", and set values for HDRGainMapHeadroom, HDRGainMapVersion. But nothing was written in. Perhaps your guess is true, and the name space for HDR is private.
But anyway, this way might help you.
new_meta = CGImageMetadataCreateMutableCopy(metadata), while metadata is from one HDR file from your iPhone. Then, CGImageMetaDataSetValueWithPath(new_meta, nil, "your_key", "your_value") works.