I have a MSM file from a third party tool. We customize the MSM with a small script and this tool is integrated into our installer and works fine. All modification is done w
Any MSI Tool can consume an MSM file and compile a MSI from it, with whatever additional constructs you want - conceivably also the changes you make to the MSM?
The free and open source WiX Toolkit would certainly be able to compile an MSI from an MSI via the command line, and it is free and open source as well. WiX Quick Start Suggestions.
However, there is cause for concern with regards to the modifications you intend to make in the MSM. This is very bad news indeed, since MSM files are specifically made to not be change by end users. It would be very good if you can find an alternative way to do the changes needed, for example custom actions inside the MSI file you compile.
Although WiX is quite involved at times to deal with, merging and MSM could not be simpler:
Full sample here: How To: Install the Visual C++ Redistributable with your installer. And the documentation: Merge Element.
Why do you want to merge this MSM every time? Is it continually updated? If so, can the vendor change it so that you do not need to post process it? If it is not updated, can you just change the MSM itself? Not great to do - in fact quite terrible - but it might be less error prone than continuously fiddling with its settings.