This (straw) man scenario feels like a proximate cause versus root cause situation to me. You've managed to establish a relatively strong
proximate cause (or so it seems) as "won't take his meds". Where did he get the meds he was supposed to take? How is he paying for them? Was he given the meds in a place of safety and security enough to have reason to trust the meds might help?
If you were given strange meds that you don't understand anything about by someone who wasn't your personal doctor in a situation that feels like a prison out of your control, would you take them?
That's equally a straw man question, but a useful one to maybe establish empathy for the situation that homeless "guy" might have found himself in.
That's also assuming that is the correct proximate cause. As far as I know science has not yet found exactly a "don't use excrement as spray paint" drug. There are people that will do that which don't need meds and there are people that will do that even on most anti-psychotic meds.
But let's talk about some of the root cause of it all: If you find yourself in a world that you cannot control, that won't let you use any bathroom without buying a coffee/being a customer, that doesn't want you to exist, that says you are only as valuable as the property that you own but then won't allow you any longer to own any property due to some bad luck or misfortune, at that point "the only spray paint I have to send a message about how much this world sucks" might seem pretty clear.
I find it easy to have sympathy with that sort of (straw) man, because there is a logic to it. It's not necessarily a psychotic break. At least, not necessarily at first a psychotic break.
What would I personally do to prevent that? I'd try to prevent people from being homeless in the first place. I'd try to get people mental health resources sooner ahead of crises rather than trying it do it in the middle of a different one (bankruptcy/homelessness). Which is the same as I suggested statistically seems to be the only thing that works: give people private houses with locks and keys and help them feel safe and secure in them, with a sense of ownership and privacy, and with no need to "earn" it or "rent" to keep it. Maybe it doesn't stop the person from covering "their own" walls in feces until they feel safe and secure enough (and that's still a public health problem in the meantime) to try an antipsychotic med that they need to take. But as far as I'm aware no one wants to take or trust an antipsychotic medication if they don't at first feel like they live in a safe enough or secure enough place.
Which again also circles back to "institutions are almost the correct approach, but for the wrong reasons" I mentioned before. A place with mental health resources seems to be an important part of that, still, but I don't think you can address mental health problems in a prison, especially in a society that values private property and private spaces, without first addressing the problems around homeless not having access to private property and private spaces.
But yeah, that's mostly just my opinion on the subject based on statistics and studies that I've read. You don't have to take my word on it. One archived secondary source (with additional links): https://academicweb.nd.edu/~rwilliam/ndonly/readings/SocProb...