Encrypt folder on Mac without dmg file so that the contents can expand in size
You can use a sparse bundle which will expand when the contents increases in size.


Enable advanced image options in Disk Utility.

defaults write com.apple.DiskUtility advanced-image-options 1

Open Disk Utility and select File → New → Disk Image from Folder… or press ⌘N.
Select the folder that you want to encrypt and press Image.
Choose sparsebundle as the Image Format, and choose the level of encryption you require.
Choose a password to encrypt the image and click OK.


If, after removing some files from the sparse bundle, you wish to decrease its size, you can compact it:

hdiutil compact /path/to/folder.sparsebundle