I don't know if this helps, but I have a shell script for backing up mysql that requires the root mysql password. What I do is store a base64-encrypted version of the mysql root password in Pillar and then write that value into the script, which in turn gets decrypted on the fly by another script, so something like this is in the script template:
MYSQL_ROOT_PASSWORD=`/usr/local/sbin/b64crypt -d "{{ salt.pillar.get("mysql:encrypted-root-password") }}"`
The b64crypt script works by encrypting (-e) with this command:
echo $PLAINTEXT_PASSWORD | gpg --symmetric --passphrase "`dmidecode -s system-uuid`" --no-use-agent --no-mdc-warning | base64 --wrap=0
and decrypting (-d) with this:
echo $PLAINTEXT_PASSWORD | base64 -d | gpg --quiet --decrypt --passphrase "`dmidecode -s system-uuid`" --no-use-agent --no-mdc-warning
The use of the dmidecode command ensures the password can only be decrypted on the server where the password was encrypted, i.e. the mysql backup server in this case (unless someone has that systems uuid, of course). So I manually encrypt the root password using the script and store the resulting base64-encoded string in Pillar.
I haven't touched this code in quite a while (originally set it up back when I was using Puppet), but I could see writing some custom Salt extension (execution module?) to deal with the crypto stuff "natively", eliminating the need for an independent shell script and factoring in use cases where you don't have complete control over the programs that require an unencrypted password string in a configuration file.