The problem is that it’s not a single memory, it’s the sum total of how they all fit together, in combination with any characteristics the individual was born with. Trying to actually figure out exactly what to erase and what to leave would be virtually impossible. It would be easier to erase everything, but then you have to build the person from the ground up or they’re just a vegetable. So in that case you have to figure out how to build a whole set of false memories that work.
Maybe then the answer, on a technical level, is that you erase their whole memory, give them back just enough to communicate and handle basic tasks, and put them in an institution that is designed to provide a positive education and produce nonviolence. Then you get punishment, they get locked up, but there is no worry about escape or release or about violence against other inmates or staff. Given the state of our prisons, mental institutions, and education system, maybe that’s just as impossible as building and implanting false memories.