It’s definitely possible. A DNG is just a TIFF file with specific metadata and renamed DNG. The metadata can be added with exiftool, Loading .raw images (from industrial cameras) - #7 by Entropy512 has an example of doing it for bayer data.
Non-bayer DNGs are also possible, it’s often referred to as “linear DNG”, although DNG also supports nonlinear encoding too. SamplesPerPixel will change as will PhotometricInterpretation. I’ve worked with non-bayer “linear DNGs” before but never synthesized one.