At least in bash you could do:
find /your/path -iname *.lock 2> /dev/null > filename0.txt
This will give you a list like this:
sed to cut the
sed -e 's/\<[.a-zA-Z0-9.]*[lock]\>//g' filename0.txt > filename.txt
You can then use
--exclude-file="/path/to/your/filename.txt" when performing a backup. In
restic help says you can use this flag multiple times, so you don’t have to worry if you have a “static” exclusion list elsewhere. If this
.lock files are changing, you can do the
find thing every time you will run the backup. It is not ideal but you can easily script it and stop worrying about having to do the two steps every time you need to run a backup.
I made this script just to see if it works for me and it does. My test directory contains 6 sub-dirs and 3 of them have
.lock files. This is the output of the latest snapshot when I use
repository b9349ed1 opened successfully, password is correct
snapshot 87970e1c of [/home/dj0k3/testdir] filtered by  at 2019-02-22 11:53:02.466103641 -0500 EST):
Sub-dirs 2, 4 and 6 contains those lock files. This is the little script used:
find $BACKUP_DIR -iname *.lock 2> /dev/null > $tmplist
sed -e 's/\<[.a-zA-Z0-9.]*[lock]\>//g' $tmplist > $tmpexclude
echo "Excluding the following directories containing a '.lock' file:"
cat -n $tmpexclude
echo "Starting Backup..."
restic backup -v --exclude-file=$tmpexclude $BACKUP_DIR