As suggested, you might use a combination of squashfs (for compression) and AUFS (to stack and merge filesystem layers together). Where AUFS stands for yet Another Union File System. But how is that implemented? I offer here a simple example script to implement squashfs/aufs...
But first, I find that aufs is supported for the Debian kernel, but not for Ubuntu :-( So provided that your distro is proper Debian-based, we can proceed to install some basic tools, thusly
apt-get install squashfs-tools aufs-tools
And now to the commands. The mksquashfs command is used to compress directory(s) into compressed modules. Two squashfs modules are created here, and mounted to make their files accessible. We then create an aufs, with one writable branch, and two readonly branch (ie. the squashfs). The options provided to the mount command specify the branches (see man aufs). Finally, we create a file, to test that file changes do indeed get written to the writable layer.
So I hope this is helpful.
#!/bin/bash
# apt-get install squashfs-tools aufs-tools
# The aim:- to create an aufs/squashfs that merges the file contents of /etc and /sbin
mkdir -p temp/{ro1,ro2,changes-dir,aufs-dir} && cd temp
# compress the files of etc and sbin into squashfs modules
# using /etc and /sbin only becos they are handy
mksquashfs /etc etc.sqsh -b 65536
mksquashfs /sbin sbin.sqsh -b 65536
# now mount the squashfs modules to make their files accessible
mount -o ro,loop etc.sqsh ro1
mount -o ro,loop sbin.sqsh ro2
# AUFS is the acronym for Another Union FileSystem
# mount aufs with 3 branches - a writable branch, and two readonly branchs
mount -t aufs -o br:$PWD/changes-dir=rw,br:$PWD/ro1=ro,br:$PWD/ro2=ro none $PWD/aufs-dir
cd aufs-dir
echo " make some file changes here, to prove the aufs filesystem is writable"
touch rofl
cd -
umount aufs-dir
umount ro1
umount ro2
# and finally we look into changes-dir, to see the stored file changes
ls changes-dir