Creating a custom (select) field and update option values from php
The hook you are looking for is hook_civicrm_customFieldOptions. Example from the docs:

function civitest_civicrm_customFieldOptions($fieldID, &amp;$options, $detailedFormat = false ) {
    if ( $fieldID == 1 || $fieldID == 2 ) {
        if ( $detailedFormat ) {
            $options['fake_id_1'] = array( 'id'    =&gt; 'fake_id_1',
                                           'value' =&gt; 'XXX',
                                           'label' =&gt; 'XXX' );
            $options['fake_id_2'] = array( 'id'    =&gt; 'fake_id_2',
                                           'value' =&gt; 'YYY',
                                           'label' =&gt; 'YYY' );
        } else {
            $options['XXX'] = 'XXX';
            $options['YYY'] = 'YYY';
        }
    }
}