You can build two different binaries then manage /usr/bin/emacs as a symlink to your actual binaries.
Gentoo does a similar thing with “eselect emacs”. I think eselect is written in bash so you could easily bend it to your needs
Also gnu store maybe does what you want