Candygram a derived form of the word telegram, where the suffix -gram means "sent from someone else".
Officially, NOAD says that the suffix -gram means:
in nouns, denoting something written or recorded (especially in a certain way):
cryptogram | heliogram.
However, at least informally, the suffix -gram has come to be used by companies that deliver things other than messages, presumably because candygram sounded more catchy than telecandy. Other quaint forms I've heard include pajamagram, a website that lets you order pajamas online and send them to someone else as a gift. There are websites called flowergram and candygram as well, and kissograms have been around for some time.
If I sent you a candygram, it might look something like this:
That explains what a candygram is. In the crime drama you are citing, a pun is being made on the phrase "send a message.” In the criminal underworld, when we send a message to someone, that means we are warning them about something we don't appreciate, often under a threat or act of violence. (As an example, there's the famous horse head scene in the movie The Godfather.)
So when they see the victim on the street, one investigator asks, "Are they trying to send a message?" meaning, "Are they trying to intimidate someone, or maybe warn some group about more potential violence?"
The other makes a grim joke, because one way to send a message (like a nice message, to a close friend) is a Candygram. He may have just as well said, “If so, it’s a pretty brutal message indeed,” but I assume the writers thought the use of the word “Candygram” would make the dialogue seem more clever. This sort of verbal exchange is not uncommon on television crime shows.