$ npx hardhat compile
If your contract requires extra constructor arguments, you'll have to specify them in deploy options.
$ CONTRACT_NAME=Parrot npx hardhat run --network rinkeby scripts/deploy.js
$ npx hardhat verify CONTRACT_ADDRESS --network rinkeby
You generally should not need to do this simply to verify in today's compiler version (0.8.x), but should you ever want to:
$ npx hardhat flatten {contract file location} > output.sol