How to Modify CiviCRM settings file
You can use $civicrm_setting variable to over-ride your CiviCRM settings. You can find documentation here.

To set extension directory you can use below snippet

global $civicrm_setting;
$civicrm_setting['Directory Preferences']['extensionsDir'] = '/var/www/html/trcbtp/drupal/sites/default/civicrm_extensions';


You can also use civicrm token variable for dynamic path

1. [cms.root]
2. [civicrm.root]
3. [civicrm.files]


HTH

Pradeep