You can use CloudLinux Selector to enable or disable the allow_url_fopen directive in cPanel.
1. Log in to your cPanel account.
2. In the Software section, click on Select PHP Version.
3. Under the Account Global Settings, go to the Options tab.

Note: If it shows an error related to the Native PHP version, change to a non-Native PHP version first.
4. For enabling allow_url_fopen, checkmark it. For disabling it, uncheck it.

The message will show that the option is enabled or disabled.