Is it possible to use an iPhone as an external encrypted drive accessible by iOS and any unix-based OS?
The short answer is, yes. There are a huge number of file manager apps out there. The trick is to find one which is (a) secure and (b) provides a webdav server so you can access the files on the device from other machines on the network (via a web browser or other webdav client).
I use Files by Olive Toast, which certainly fits your second criterion. Another one which looks like it would is EZ Server by Lisa Burns.
Regarding security, it depends what you're looking for. Do you want the files stored in encrypted storage on your iOS device? That's how iOS works for everything. Do you want them protected by a password? Isn't your iOS passcode enough? Do you want the webdav server to support https? Probably only necessary if you're using public Wi-Fi networks.