This is/may be more than just a matter of images being included in the atlas.
Even if it's not keyed and not visible in setup mode, the attachment will still exist in the SkeletonData. So when the runtime loader (standard implementation) tries to load that attachment, it will fail, and in most runtimes, including Unity, it will just fail to load/throw an exception.
So just excluding it from the atlas is not quite the solution.
Unchecking the "Export" checkbox on an attachment will exclude it from both the skeleton data and the atlas though, as @Shiu mentioned.
Currently, I don't think we have an option that automatically excludes unused attachments from your export.