Murder in and of itself isn't all that heroic an action - as the countless prisons filled with those convicted of manslaughter and various degree of murder may have already suggested to you. But, under the right circumstances, it can be, as is the case with Thanos killing his future self in Donny Cates' Thanos Wins series.
Though the pair of purple people-killers do team up at the start of the series, the young Thanos quickly sours on his older counterpart, as he realises the old man is obsessed with murder not to assert his own power, but out of worry that he'll never properly see Death again. He's living in fear due to his profound desire to die and be reunited with her.
Realising that his future self kills countless people not in a bid to change the world but rather out of weakness, Thanos steals the Time Stone, and tells his doppelgänger that he won't kill him, and he won't do any of the things that got him there - which means he effectively saves the lives of half the Marvel universe by refusing to walk in his old footsteps.
While this may not sound profoundly heroic, the fact that Thanos saw a universe where he got everything he'd been after his whole life, and actively rejected it because he felt it was dishonourable, is a surprisingly moral move.