How to install or upgrade a third-party module from Packagist to Magento < 2.4.2 after Packagist has restricted access to its packages via Composer 1?

A solution:

Step 1

Install Composer 2 alongside with Composer 1.

Step 2

composer2 require --ignore-platform-reqs --no-plugins <your package>

As a side effect, this step could undesirable upgrade some other packages to versions which require PHP newer than you have installed.
It is fixed by the Step 3.

Step 3

composer update

This step will revert other packages (mentioned on the Step 2) to a compatible PHP version.