Greetings, sorry about the pai.
You have an muscle imbalance at shoulder which is causing you the trouble. You neck and shoulders are linked so whichever gets pain can create discomfort at both areas.
Next Steps
ice to shoulder and neck thrice a day or as needed for 5 minutes. get to see a physio specialised in posture correction, it is the best solutions both short and long-term. in mean time use a sling to rest it. treatment approach is relieve pain plus correct muscles which are not having correct length to hold joints in proper alignment. which is the reason you get clicking sound. note - exercise is required but not at this stage, physio is the best person to decide how to start exercise.
Health Tips
avoid writing or minimise it and also avoid sleeping on affected shoulder. if unable to get a physio or if problem still persist for various reasons you can get treatment from my clinic. be assured it can be treated and cured permanently.