From the CLI, after you create your token per the documentation, you could mint the total supply to a wallet to be the authority of the supply using spl-token mint
(docs).
After the supply has been minted you can use the CLI to revoke minting authority, preventing any tokens from being minted again (docs):
spl-token authorize mint --disable ...
This will set the mint authority to None
and prevent any more tokens from ever being minted. You can run spl-token authorize -h
to get more help and options on the command.
If you would rather create a "cap" without minting all of the tokens first, you'll probably want to create a program to manage the token minting and programmatically define a cap. Here are examples for how to create a program that manages token minting--you'd need to modify to meet your specific logic.