The documentation is a bit tricky and also the updates in different versions can be missleading. What I found is:
first : mongodump needs to be run from the shell, not from the mongosh shell (https://www.mongodb.com/community/forums/t/syntax-error-missing-semicolon/203269?msockid=3d84573c4efb6f172cdd427e4fd36e19)
second, you may need more arguments (like the port and the username to do the export), described in the documentation (https://www.mongodb.com/docs/database-tools/mongodump/mongodump-examples/#copy-and-clone-databases)
third, at the end of a statement like this:
mongodump --archive="<the-new-db-name>" --db=<the-db-to-copy>--host="localhost" --port=<e.g:27017> --username=<your-username> --authenticationDatabase=admin
, you may be asked for a password. after the correct password it will write and dump
Note: And you will have your file "archived". if you want it as an output file, you will need to change the "archive=" statement by "--out="
Note2: I am ussing MongoDB: 7.0.5 and Mongosh: 2.1.4