Mars refused to comply, so Earth imposed economic blockade. Mars is still dependent on many critical things from Earth so they cannot just wait. They threat to make nuclear, biological and ecocidal bombardment of Earth if blockade is not lifted.
Even ignoring the events that led up to the blockade, this is where what you describe gets outright surreal. Let's outline the sequence of events, in the orbital-altitude level of detail:
- Mars is totally dependent on Earth.
- Mars angers Earth.
- Earth institutes a blockade against Mars to force Mars to comply with Earth's demands.
- In response, Mars goes to war against Earth, in a way that is virtually guaranteed to cause massive damage to Earth's biosphere and population.
- Mars expects that after such a threat, Mars and Earth can just go back to being old-time buddies again.
The old saying goes you don't bite the hand that feeds you. There is a lot of truth to that here, simply because of the total dependence of the people on Mars on the good will of the people on Earth.
Dropping massive amounts of nuclear weapons on the people that you want help from seems to me like, very generally speaking, a not particularly great long-term strategy. In fact, it sounds like a lousy short-term strategy as well.
As for your actual question, how Earth could defend itself in this scenario. Well, we have two main options. We can't really move the Earth out of the way, but there are the installations on the Moon (which could, at least in theory, be pressed into service as a launch platform, taking advantage of the Moon's shallower gravity well if the material is already there; we gain no advantage if we have to transport materials there first), and there is the option of launching something from Earth.
For completeness' sake, the Moon's gravity well (at 2.38 km/s escape velocity) is far shallower than either Earth's (11.2 km/s) or Mars' (5.03 km/s). Those of you reading this who don't know why this is a big deal, keep in mind the tyranny of the exponential nature of the rocket equation. It's not a perfect comparison, but you could compare even something like the Falcon 9 with the Apollo Lunar Module, specifically the ascent stage.
In an unpowered transfer orbit, which is the best you can hope for if you basically hurl "barrels of pollutant or dangerous bacteria" at another solar system body, it's not like the weapons are doing a lot of maneuvering. Rather, they are going to be coasting along at likely some small above-parity fraction of the origin body escape velocity, along an orbit that can be trivially calculated. Even at closest approach, Mars is a minimum of about 55.8 million km away; at 6 km/s, even if you could go in a straight line (which you cannot), even that would be a 108 Earth days trip.
The obvious option is a powered interceptor. This would be akin to New Horizons, only far easier to pull off (and probably needing a bit more fuel for maneuvering, but far less to get it onto an appropriate transfer/intercept orbit). Earth has at the very least months, and more likely 1-2 years, of lead time before the impact. A small nudge (at a guess, meters per second of delta-v could be plenty, if applied early enough) could disrupt the transfer orbit sufficiently that the weapon misses the Earth and potentially hits Mars instead.
An alternative approach would be to send something that makes a sufficient boom (which need not be a large one) to damage the weapon containment vessel. That would either cause the outright destruction of the weapon, or leaking of its dangerous substances into space over time, where they would be essentially harmless. Earth would still potentially have to deal with the impact in the latter case, but it would be less of a problem (and it's much more likely that atmospheric reentry would take care of it, then).
A third possibility is that the people on Mars would need some way of preventing a disaster on Earth if the conflict ends while the weapon is in a transfer orbit. Figure out the specifics of that process and replicate it, or bring out a large wrench.