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?

New versions of Composer packages published on Packagist.org are not available via Composer 1:

new packages and old unused packages will only be visible to Composer 2 until someone installs them, at which point they will become visible to Composer 1 as well (within 24h as this process happens on a nightly basis).

blog.packagist.com/deprecating-composer-1-support/#restricted-access-to-unused-packages-via-the-v1-metadata-api-starting-in-may-2021

Magento < 2.4.2 does not support Composer 2.
How to install or upgrade a third-party module from Packagist to Magento < 2.4.2?

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.