Yes, you made a pun. A pun is a form of word-play in which a word or phrase is used simultaneously for two of its meanings, or similar-sounding or similar-looking words are exploited for a double meaning. Both meanings make sense, at least somewhat, in the same sentence.
In your pun, your friends used the word sweet to mean having a pleasant and kind personality, and your response switched to the meaning of having a pleasant flavor like that of sugar.
Here are a few puns by, or at least attributed to, Groucho Marx, one of the best English-language punsters of all time:
Time flies like an arrow. Fruit flies like a banana.
Anyone who says he can see through women is missing a lot.
You can leave in a huff. Or you can leave in a minute and a huff.
Everyone must believe in something. I believe I'll have another beer.
Outside of a dog, a book is man's best friend. Inside of a dog, it's too dark to read.
Most successful puns are quick and spontaneous: unplanned, they fit the situation well and they aren't funny if retold later. And most successful puns play off of a familiar phrase, not just a word on its own: "flies like an arrow", "leave in a huff", "a minute and a half", etc.
Most puns, however, make people groan, so I'll stop there. Hopefully that's enough that you can see what the concept is.