Ran into the same question today and found this post.
Although the above solutions probably work, I found a recent post with a much easier solution since Xcode 13 is out.
(especially the archive script at the and of the article is very cool :) )
https://scriptingosx.com/2021/07/notarize-a-command-line-tool-with-notarytool/