You cannot use Pulumi.yaml for this, it doesn't support secrets (and it would be hard to get it to, since Pulumi-managed secrets are encrypted with a stack-specific key).
If Pulumi ESC isn't suitable for you, you can use any encryption library your chosen language supports, and store the encrypted value in a local file. However it's probably worth taking advantage of a vault of some kind so that the secret is available from any machine but not stored in your git repo (even encrypted).