Hurt muscles in right neck and shoulder shoveling snow. Stretching muscles hurts. Is it good to stretch sore knotted muscles?

Yes. Gentlle stretching is usually helpfull. Oltherwise the muscles tighten and this can cause symptoms to worsen.
See a physician. You probably have a trapezius strain. You should consult your physician. Your symptoms are caused due to muscle spasm. Your physician can prescribe you some nonsteroidal anti-inflammatory medication and muscle relaxants and or physical therapy which will help to alleviate your pain.