You will need to install some dependencies first, (with apt) at least:
autoconf
make
g++
libgpgme-dev
Then for any given php version, run (example for PHP 8.4);
/opt/ecp-php84/bin/pecl install gnupg
Lastly add a php.ini directive for extension
set to gnupg.so
. You can do this globally, per server or per-website.