Yes, I have declined and been hired by the same companies. It is far less career-ending than it feels.
How to do it without it reading as a refusal to be assessed - offer an alternative rather than saying no:
Point at existing work. A repository, something you have shipped, an open source contribution. Many places accept this happily and never mention the exercise again.
Offer a live session instead. An hour pairing on a problem of their choosing. This is often better for you - they see how you think and ask questions, which a submitted zip file cannot show.
Ask for a smaller version. I am glad to do this and I can commit about two hours; is there a reduced version, or shall I do the core and we discuss the rest.
That last one succeeds surprisingly often, because the person on the other end frequently knows the exercise is oversized.
What to avoid: declining without offering anything, and complaining about the industry in the email. Both are read as difficult rather than as principled.
And if they insist on the full thing with no flexibility and no conversation first, that is information. You are early in a process with a company that has already decided your time is cheaper than theirs.