That's one of the stories behind the phrase, and it seems the most plausible. The second involves some explanation about a piece of equipment called a "dam" to ensure the molten metal they used didn't get away from them, and which was discarded after use and therefore worthless. But that seems to have been created as a more genteel explanation and doesn't try to retcon "cuss" into it.
Thoreau uses the "damn" phrase, even, and that Thoreau, he was a pretty smart guy. (And I don't even mean George K. Thoreau, who indeed is smart, but good ol' Henry D.)