How? Treating them badly would just make them more, not less, likely to romanticise their cause. Just as if Jefferson Davis had been hanged in 1865, the carving of him on Stone Mountain might today be even bigger than that of Lee, rather than smaller as OTL.
I disagree on the martyr argument. Most of the romanticization happened decades after the war into the early 20th century and beyond, mainly to validate the current segregation practices.
The government wouldn't have had to punish all southerners just those that tried to cling to the confederacy and its figureheads. Eventually most of the population would have realized it would be easier to just forget about them than have to deal with the repercussions to revere them.