A value set with pulumi config set --secret is encrypted before it reaches state, and stays encrypted in the state file and in pulumi stack export output. The encryption key comes from the stack's chosen secrets provider: the Pulumi Cloud service by default, or a passphrase, or a cloud KMS key when --secrets-provider was given at stack creation.
The consequence is that a state file alone is not restorable. Exporting a passphrase-encrypted stack and importing it elsewhere without the passphrase yields a stack whose secrets cannot be decrypted, and pulumi up fails at the point it needs one. The passphrase is read from PULUMI_CONFIG_PASSPHRASE or its file variant in CI.
Changing providers after the fact requires pulumi stack change-secrets-provider, which re-encrypts. Note also that secretness is contagious in one direction only: an output derived from a secret input is marked secret automatically, but a value written into a resource property that the provider then returns unmarked can surface in plaintext. Use pulumi.secret() to mark such values explicitly.