You may put anything in a dmg, it behaves like a (fake) external or internal disk.
A keylayout works if:
1. Create a keylayout file and add an icns file, in order to have a custom icon of it; the icns file is not mandatory, if absent the keylayout will have a generic greyish icon. In order to install it, you will drag the two files (or only one, the .keylayout file) to /Library/Keyboard Layouts. The original will remain in the dmg file.
or
2. Create a bundle file, which contains one or more keylayout files associated or not to their icns files, and put it in the same place.
For the time being, I abandoned creating bundle files, as some apps, in my case Nisus, cannot recognise the language-specific code and does not pick up data from a bundle, so I reverted to the classical method of a .keylayout file + .icns file.
Of course you may install them in any computer running any OS from the immemorial 10.2 (I guess) to the last version. For older OSs, use the ‘classical’ method quoted under #1, they will not recognise the bundles.