ssh-keygen -t ecdsa-sk -O resident -O application=ssh:YourTextHere -O verify-required
To use the ed25519
curve (requires a YubiKey with firmware 5.2.3 or higher), use the following command instead:
ssh-keygen -t ed25519-sk -O resident -O application=ssh:YourTextHere -O verify-required
For both commands, YourTextHere
can be replaced by anything which helps you identify where this key is being used, for example a server name. This is not a mandatory option.