Please utilize Ansible… you almost never want to run commands like that on your servers. You should be modifying your configuration and then provisioning again. There is no harm in provisioning servers again. That is how you should be applying configuration changes
You can define php_extensions_custom in group_vars/all/ rather than overriding that file, allowing you to more easily upgrade Trellis in the future