Thanks for mentioning this. I think I've occasionally had DNGs in the wrong orientation but never connected it to a specific cause.
The orientation value we use (PROPCASE_ORIENTATION) updates essentially in realtime, you can watch it change as you move the camera around. It's not connected to shooting, but it's possible that it stops updating in some parts of the shooting process. CHDK captures this value as soon as the image data is available (the start of the raw hook)
So my best guess would be that the orientation is changing between when the exposure ends, and the raw hook starts. If this is correct, delaying the DNG process would only make things worse. Also, if the jpeg comes out right, that would mean the value used for the jpeg exif is either a different propcase or is captured at earlier.
Not sure about fixing this. If there is a separate propcase that updates on shot used for jpeg, that would work.
It's also possible my theory above is wrong. Some logging could probably be used to determine that.