I found myself in a need to filter away some licenses for my dependencies (AGPL, I'm looking at you). I've found a well known plugin for that: metasyntactical/composer-plugin-license-check.
The problem that I found with it is that it doesn't prevent you from installing blacklisted packages. I mean it was designed to do that but fails on Composer 2.0+.
I started investigating for the ways to fix that but ended up with a feature complete plugin. It also offers some more flexibility in the config.
Grab it here: https://sandfox.dev/php/composer-license-manager.html