My OTTB is also a weirdo in his stall. . . he does lots of strange things, but one of them is pooping in his feed bucket! He also poops in one corner and pees in another– it seems that if the poop corner is already full of poop, he goes in his bucket.
Two things worked for me: we moved to a barn where the stalls are better kept, and they scrape the stall all the way down each day, completely removing ALL bedding, not just the dirty stuff. I have always removed any visible poop or pee, but having brand new shavings each day also seems to really help. I would say just make sure your barn’s stall care is up to your horse’s standards.
The second thing that worked is hanging a “dummy bucket”. I actually have two dummy buckets– one for him to use as a toilet, the other filled with water for him to soak his hay (I know that’s a sign of ulcers; he’s being treated!). Our new barn also has a fixed “feed trough” like bucket thing which is shaped more like a feed pan and screwed into one corner of the stall– he doesn’t seem to poop in that. I even wonder if he used to poop in his bucket so he could swing it around and play with it– like I said, he’s a weirdo!