Oof, I didn’t know that about firejail. I’d heard of it, but I’d never used it. Like, c’mon folks! If you need privilege escalation, either require launching as root (if appropriate), or delegate the responsibility to a small, well-audited tool designed explicitly for the purpose and spawn a new privileged pid. Don’t use SUID. You will fuck it up. If you reach the point where setuid is your only option, then you’ve hopefully learned enough to rearchitect to not need it, or to give up, or use it if you’re, say, someone who maintains a libc or something.
EDIT: this is overly dramatic, but also it’s not. I personally feel like using SUID is kinda like rolling your own crypto in terms of required competence.
Sounds like you may want to use a union filesystem like overlayfs. I’m not sure if the specific behavior of overlayfs will work for you, but it’s worth investigating.
Thank you for putting your use-case in your post, since otherwise I think this might be an XY problem.
EDIT: There’s also mergefs and unionfs. I don’t know what the features and drawbacks are for these three union filesystems. mergefs seems like it might be the most configurable, but it’s also FUSE. unionfs and overlayfs are both in-kernel, so they’ll perform better (which may not matter for your use-case). overlayfs is the one I’m most familiar with of those two, since it’s used by most container runtimes.