No, XMP data is not written to the RAW, it is written to a separate XMP sidecar file. This is how it is in the standard.
EXIF and legacy and GPS metadata exists twice: once in the RAW and, as mapped copies, in the XMP. Hence the need to synchronize forth and back.
Recently some camera vendors started to add XMP directly to the RAW. Usually, an incomplete XMP record containing only the
rating=none field.
Probably to support some in-camera rating or similar.
And this creates a new set of problems, e.g having two XMP records for a RAW. The standard record in the XMP sidecar file and another XMP record in the RAW, with a hard-coded rating=none.
Why camera vendors still stick the problem-ridden and 30 year old EXIF metadata escapes me. They could store the same info as XMP, including all their proprietary and undocumented maker notes.
Until now I have never changed a RAW file.
A RAW is just a TIFF file, with a "heap" (data block) containing the Bayer mosaic data produced by your camera. All else is like any other TIF. There is nothing holy or secret with RAW files.
This discussion of whether or not the metadata in a RAW should be modified ran for years. And, frankly, unless you work for the police or insurance business and you have to maintain chain of evidence, it does not matter. And in these businesses, you are using special cameras with special RAW formats anyway.
Having different EXIF, legacy IPTC and GPS data in the image and the XMP causes way more problems. Best to keep everything in sync, nice and shiny.