[Galaxy S6 Edge Q&A, Help & Troubleshooting] Quigley:
I've been through this -- but I think the hidden partition does not contain your IMEI (see here and here). The firmware package's hidden.img.ext4 file contains (perhaps among others) the /preload partition (mount point), which contains additional stuff, sometimes carrier-specific apps and such I believe (see here and here). The main reason for /preload is that things don't fit in /system anymore, so /preload provides additional space.

Of course, your current partition configuration and sizes have to accommodate all partition sizes you want to flash. If the partition configuration and sizes on your phone do not correspond to the firmware you want to flash, some partitions might not fit. And apparently this is what happens with the /preload partition. Some models have different partition sizes, with /preload being too small, or may lack the /preload partition altogether. I guess what Samsung did when they realised that /system was too small for some updates they symlinked additional stuff from /preload. Some other phones (e.g. with less carrier customisation) do not have the /preload partition. These consist mostly of phones that have unbranded (non-carrier) firmware, I think mostly denoted as multi-CSC, about which you can read here.

For custom ROMs, /preload is hardly used (they also tend to be smaller I think, but see the post I linked where someone calls for using it). So if you have a custom ROM, you might just delete the /preload partition (see here). But also, without symlinks it can do no harm. You might repartition your device of course, using a PIT file that has a larger /system and no /preload, but re-partitioning is a little risky unless you know what you're doing.

What people did here and here (and plenty of other places) is to just flash a stock firmware without the hidden.img.ext4 file in it (repack it and skip MD5 check). Then they flashed the hidden.img.ext4 separately afterwards. I have up until now no clue why that does seem to work. For me it did too. However, I now have the 'failed to mount /preload' error in TWRP.

EDIT: It seems the hidden/preload partition does not flash the second time at all. The system still boots however, because usually that partition does not contain much essential stuff (see below). So the best thing to do (especially if you want to return to the stock ROM as much as possible) is to look for a ROM which is meant for the localisation of your device (i.e. has the same partition sizes so it just all fits).

To obtain some more information on how to list your current partition table from within an Android phone, see here.

To really know what's inside the flashable partition files you can use a tool simg2img to convert the sparse ext4 files to raw ext4 image files. For example the hidden.img.ext4 file of one particular S4 mini ROM I flashed has the following contents:

├───Common_app
│ (Deezer)_Deezer_4.2.3.1.apk
│ (Embedded_Games)_TOP_GAMES_1.0.0.apk
│ (My_T-Mobile_NL)_My_T-Mobile_NL_2.3.2.apk
│ (Shazam)_Shazam_4_6_1-85860.apk
│ (Travel_&_Surf)_Travel_&_Surf_NL_2.0.2.apk
│ ebaymobile_signed_2.5.1.1.apk
│ groupon-2.10.3166.apk
│ hrs_and_preinstall_4.7-rev10287p-release.apk
│
├───INTERNAL_SDCARD
│ │ .bugsense
│ │
│ └───Samsung
│ └───Music
│ Over_the_horizon.mp3
│
├───lost+found
├───symlink
│ └───system
│ └───app
│ Books.apk
│ FaceLock.apk
│ Flipboard.apk
│ Gmail2.apk
│ Magazines.apk
│ Music2.apk
│ PlayGames.apk
│ talkback.apk
│ Videos.apk
│
└───[SYS]
Journal

As you can see, it's full of crap, along with some system apps which are symlinked from /system.