A lot of microcontrollers these days have self programming capabilities - i.e. they can write "code" to their own flash during operation. Ive been working on a project which uses such a capability to enable "firmware upgrades" to be applied once the MCU is soldered to the board without requiring the use of ICSP - as many others have done before me. I also use some of the spare space to "emulate some EEPROM", since the MCU I use doesnt actually have any built in EEPROM.
So in theory, yes, you could do something like this, but the question becomes whether it is practical to do it, or to build a system that is better suited to the many tasks you want it to do. e.g. a small processor and some external memory and flash storage that can hold all of the code that might need to be executed for all of the required scenarios is not impractical to achieve. Re-programming the device on the fly just to switch between one mode or another just sounds like you should have chosen a device with more space for storing code really... What you save on internal flash you could easily spend, and then some, on external storage.
Side story: Ben Heck recently did a tear down of a small hand held arcade game which infact turned out to be 3-4 different games in one, with the game set to match the branding on the case via a jumper or some such on the PCB at the factory. He modded it with a switch so that you could select from any of the available games afterwards. So certainly it seems, "burning" some excess flash for a more universal product isnt out of the question even for low cost devices.