Are there really situations where a student would be better off getting a negative letter over no letter at all? No matter what your role, I really think if you have nothing nice to say about the student, it is far kinder and more fair to tell the student something like you're "too busy with other letter requests" or "don't know them well enough to give them a sufficiently strong letter" if you can't be honest with them about why you don't want to recommend them for residency. Then they have the option to find someone else who may have a better impression of them...and if *nobody* wants to write them a letter than that really is a red flag.
Sabotaging someone's application with a negative letter is a serious matter.
I think people who don't know how it feels to go unmatched don't appreciate just how devastating and frightening it can be to find yourself without a job after all the debt and years of training. I don't have any reason to think any of my letter writers said bad things about me, but if I did find out that was why I wound up going unmatched (after wasting thousands of dollars on interviews and putting my loved ones through a lot of grief and stress) then I would be really angry at the person who thought that it was their place to try to derail my career based on a few weeks of contact that may not be representative of what I'm capable of.
If someone is so completely inept that you think they would be dangerously bad as a resident, then you should be talking to the student and their dean about remediation or something like that, rather than trying to keep them out of residency with a negative letter. If it is conceivable that your negative impression of a student could be due to a misunderstanding, a personality conflict, etc. then I believe it is never appropriate to pretend to be helping them while actually doing harm to their application.