Is there a way to encrypt a file with a Yubikey? I want to encrypt a GitLab token in a file that can only be decrypted when I tap my Yuibkey. Maybe I’m just being dumb, but I haven’t found a straightforward way to do it

Covered by the guide: see https://github.com/drduh/YubiKey-Guide#using-keys and look for "Encrypt a message to your own key".

Also, sops (https://github.com/mozilla/sops) works with gpg and so with Yubikeys.