score:9
Once you have been issued a visa, it is valid for the entire Schengen area (within the validity and duration of stay it is issued with). There's no problem with tacking a short visit to Denmark on to your conference trip, if it can be done within the allowed duration of stay.
You could get into trouble if it turns out you lied about the purpose of your visit when you applied for the visa. But given that you are actually attending the conference you said you would attend, you did not in fact lie about your purpose and main destination, and changes to minor side quests do not affect the validity of the visa at all.
Note well that even if you didn't have a Danish friend to visit, it would be quite unremarkable for you to leave the Schengen area in Copenhagen. Copenhagen is a major hub for SAS, and if you bought a ticket from Stockholm to somewhere else you might easily end up with a Schengen-internal flight to Copenhagen and an intercontinental connection from there. This would have you pass through the very same passport control lines in Copenhagen as travelers who start their journey from Denmark.
Upvote:3
Even with a single-entry visa, you are allowed to make adjustments to your itinerary after the visa was granted. Of course you are not allowed to misrepresent your itinerary to get a visa in the first place, and it is a very good idea to avoid any false impressions in this regard.
If you cross from Sweden to Denmark with days left on your visa and tickets from Denmark to home in your pocket, it seems unlikely that you will be challenged on exit. Your overall credibility for the next application may be diminished.