Here’s a KDE Plasma service menu (dolphin context menu action) for creating a valid CACHEDIR.TAG file in the selected folder. Useful for excluding things from being backed up! (e.g. via restic with the --exclude-caches option)

[Desktop Entry]
Type=Service
MimeType=inode/directory
Actions=create_cachedir_tag

[Desktop Action create_cachedir_tag]
Name=Create CACHEDIR.TAG
Icon=breeze/actions/22/document-edit-encrypt
Exec=echo "Signature: 8a477f597d28d172789f06886806bc55" > %u/CACHEDIR.TAG

Put it somewhere like .local/share/kio/servicemenus/cachedir-tag.desktop, make it executable and it should show up in your context menu.

updated: