How does such a comment work and how do I post one?
Such comments are automatically applied if the question was close flagged / voted for the duplicate reason. There are generally two ways to place them at a question:
If a user is below 3,000 reputation, they can flag it and choose duplicate from the pop-up dialogue.
If a user has close voting privileges (3,000+ rep), they can click the close link and choose duplicate from the pop-up dialogue.
A manually constructed comment would not have the same effect, but the proposed link will appear in the Linked section beneath the question.
If the asker accepts the dialogue you've mentioned, the question will be immediately closed by Community ♦︎.
Otherwise it takes 5 users with the close voting privilege, a gold badge holder for one of the question's tags, or a moderator to mark the question as duplicate.