I recognize the devil's advocacy and will refrain from judgement on your position. In response, there are a few options (probably more that aren't occurring right now; it has been many years since I was researching this in university):
- A "need-blindness" system a la financial aid at US universities, as well as those in a few other countries. This gives deniability as its primary benefit, when people ask "why was the person with a 'self-inflicted' (replace those single quotes with very sarcastic finger wags, please) need above me?" That deniability is imperfect, and causes political problems.
- A formalized ranking of factors that influence priority for care, performed by formulae as public and precise as possible. This could potentially include 'self-inflicted' conditions as something exerting downward pressure. Much like sentencing guidelines, there will always be some subjective/human leeway in the application of those formulae that draws accusations, founded or not, of bias. Also, in libertarian political climates, this will draw accusations of governmental meddling in personal decisions.
- Pricing care at a level likely to ensure that only a number of patients proportional to available care-giving resources are admitted. This would require massive changes (mostly removals) to subsidies that exist for healthcare. This is unlikely to succeed politically, and from a humanitarian/ethical point of view is likely to be viewed extremely negatively (a view I share). It would have the advantage of making the "real" problem (lack of caregiving resources, including skills and general awareness) directly apparent, but only as a form of shock therapy.
Those are ways to address your question directly and narrowly. Secondary solutions/those with knock-on effects (preventative care etc.) are out of scope of this answer.
EDIT and as to the "when is it ethical" portion of your question (the above answers are logistical, not ethical), it's a crapshoot. It boils down to the ethical questions of the trolley problem plus the determinism problem, neither of which are generally considered to be tractable alone, much less together.