How to only write to external USB drive on Linux when it's attached?

Unlikely. After first backup, Duplicati will miss the files that its database says should be there, and error.

I’m not clear how writes hinder mounts, but if writes are a concern despite above, they can be stopped:

Making immutable mount points with chattr