Good work recognizing VERY ALARMING signs! You are right, this age is crucial. He is garnering attention by being disruptive and hurting himself, which means he has a long building sense of self hatred, this did not start over night.
You need to remain patient and positive as the norm when all is well and as a human being, but he also needs REAL COMSEQUESNCES to his actions or he will never respect you or himself. It may be too late at 12, but it may not. If you are afraid to tighten up the discipline for fear of losing him, just remember, you definitely will lose him if you do not do it.
NO COMPUTER. The computer is an extremely dangerous tool in every way. No 12 year old needs to be chatting. Don't fear his wrath. No computer until his behavior is one hundred percent changed for a certain amount of time. As in, no smarting off, no unfinished homework, no bad behavior reports form teachers. If he never gets it back, so be it. All the safer for him and his friends. These games of exibition online spiral way out of control all the time. He obviously has no ability to control himselof right now, so get him off the computer. Remove it from the house if you have to.
This is DAD'S work (as well as yours, but mainly his)! Your husband needs to give your son attention and structure at all costs for the next 6 months to year. Your son must understand that NOTHING is more important to his father than his well being and character. Hard line discipline, lots of time together, positive experiences, time around other men exerting physical energy in healthy ways, building, construction, riding bikes, sports, whatever his interests are, and NO NONSENSE when he messes up. It's now or never. Don't waffle! MAKE THE TIME.
Keep this kid busy! Idle hands are the devils' playthings. No hanging out with friends and chatting online. Time to mow some lawns, reach out in the community, earn some money, learn some skills, and go to bed tired. Get some good male role models for movie nights with dad-John Wayne, whatever. Keep his influences positive, and let him earn some privileges that are frivolous as he starts to make you proud.
Hard time accepting rudeness? You should not even be attempting to accept rudeness. Disrespecting parents is a capital offense. Treat it as such. I would not have still had computer privileges as a child if I had even given one of my parents a dirty look. Once. Buy accident.
Command respect to yourself while setting a good example. Actions speak WAY LOUDER THAN WORDS, don't reason with him. Don't repeat things a billion times. ACT. Bad table manners? Too LATE! (no harm trying to fix it, but that one's iffy) But as he improves his happiness and behavior in general, he'll be better at the table too.
Figure out with dad what to take away -COMPUTER-and what to add to his life-ACTIVITIES WITH DAD- for his own good. His life literally depends on it. I don't have to tell you what all the self injury is a sign off. You already know. All you can do is your best, so DO IT! BOTH OF YOU! Best wishes, my heart goes out to you!