How to save a config option programmatically?

Use the \Magento\Config\Model\ResourceModel\Config::saveConfig() method:

An example of usage from the core: