How to set config options from the shell?

I have two scenarios where I’d like to set options from the shell:

  1. I’d like to stop a Firefox instance from prompting to ask whether or not the user wants set it as the default browser.

  2. I’d like to be able to set options like reopen all tabs by default or to use a specific theme (light or dark for example).

Is there a way to set these via command line / shell parameters or does a config file need to be modified?

If the latter is necessary, then is there a canonical method to temporarily start up an instance to initially generate the config file and then quit it, set the option(s) and then restart the new instance?