Is there a method to clone my macOS into fresh OS installer like Windows WIM? On Windows there is this method exists: you create a backup image of the whole system (for example install all updates, tweak system parameters, harden the os, install some basic software and utilities).

This image comes with .vhd format, then you can easily convert it to .wim format and inject (in fact simply copy &amp; paste with replace install.wim file) into Windows Install usb or disk. As the result next time you can quickly install already tweaked ready for work system.

Sorry for the long preamble. So is there a such thing for macOS? I found that installESD.dmg has the big compressed 5.hfs file. I guess the whole system contains there. But I couldn't open it. 

My intention is to clone my macOS into bootable 16GB flash drive, so the clone should be compressed.

Is there a way to make a compressed bootable clone of macOS?
The concept of a registry or binding to AD means that all Macs are in the sysprep state always. There’s really no analog to needing to prepare a clone since any backup will work to drop a restored image. You can use asr or Carbon Copy Cloner or Super Duper or Time machine or APFS snapshots to make clonable images of macos including the apps, accounts, settings.

The installESD is more like the windows ISO than something that contains user date or settings.

Apple has tons of documents now on the automated install scripts to reinstall the OS - and in the past NetBoot could be used to clone and image, but macOS is now designed to do a clean install and then restore user files / apps / settings rather than slip streaming a new OS. Both get you to the same end point, automated, but the tools needed are different since you just install macOS and then run a migration script to get the data in and upgraded to the new OS if the migration is also an upgrade.


https://support.apple.com/en-us/HT208020 Install for Catalina and newer macOS versions
https://support.apple.com/en-us/HT205054 NetBoot for older macOS versions