Good evening! I'm Dr. Sara. I'm a licensed veterinarian who works exclusively with cats and dogs. I've counseled many owners on litter box aversions and have had a fair share of problems myself!! Here are some general suggestions for dealing with litter box troubles:
Cats are super fastidious, so some are very sensitive to a dirty litter box. Some cats absolutely will not pee in a box that's not immaculate, so watching the boxes for cleanliness is important. The box should be scooped at least once a day.
The ideal number of cat boxes is the number of cats in the home PLUS ONE. Each box should be in a separate spot - a cat will look at two boxes right next to each other as one box, so spread them out. Make sure there's at least one box on each floor of your home too, in case stairs are an issue, perhaps for an older arthritic cat. Boxes should be far from very noisy or unpredictable areas. A washer or dryer or furnace kicking on at just the wrong time can startle a cat and turn them off from the box entirely. Their litter box shouldn't be near their food or water - no one like to eat and dine in the same place! Also, some larger cats won't like to use small boxes, and many cats prefer that their box not have a hood. The hood traps in the odors and dust and can create an unpleasant pottying experience.
It's also a good idea to try a new type of litter. I usually recommend ADDING a new box rather than changing any of the existing boxes. If you're using clumpable litter, I'd rotate through trying pine litter (Feline Pine), recycled newspaper litter (Yesterday's News), crystal type litters, or corn cob litter. Sometimes you'll find that he will like one of these new litters better.
If these things aren't working and the situation is really desperate, I'll consider allowing them to become and indoor/outdoor cat with time outside. If they want to go outside and like to be out there, it often alleviates or eliminates completely the urinating in the home. Obviously, this approach comes with its own set of risks, but IF the choice is to euthanize them or to allow them to have some outdoor time, I'd choose the latter. I've actually done this with my own cat and it's solved our issue.
I've had some success with pheromone products like Feliway or Comfort Zone. They are geared more toward behavioral marking but sometimes can have an overall anti-anxiety effect and help with litterbox issues.
Lastly, I would do a course of anti-anxiety medication like fluoxetine. In many of my patients this alleviates or eliminates the problem. Don't ask me why they are anxious, I just know that anxiety can cause them to skip using the box ;)
Some people do consider giving their cats up to a shelter, which is a very tricky proposition. I've seen many cats come to the shelter with a history of "house soiling" who do not do it in their new homes. No idea why - but I do see it happen, so it is a possibility. Depending on the resources of the shelter, the kitty may or may not be put up for adoption. If they are really strapped for resources and don't have the space to keep them and assess them, they may have to call the kitty "unadoptable" which would put them in line for euthanasia - so I would discuss with them before you sign them over, if you end up needing to consider the shelter route.
As I said, I absolutely appreciate how difficult this problem is - I've been there myself and it breaks my heart. I miss having my cat in bed with me every night, but I also cannot have him peeing in my house. My dad is retired but he practiced as a vet for 50+ years. As you can imagine, his view on "house soiling" cats was pretty black and white - he used to say "they live in my house, not the other way around". But times have changed - they are such a part of US and our family that they are not disposable and we aren't going to just give up on them. I'm sorry that you're having to deal with this. Please let me know if I can elaborate on any of those individual things that I mentioned - as I'd be happy to do so :)