We have a cat that pulls that same trick, exactly what you describe. She'll go in the box to pee and then come out and poop right in front.
Spraying Feliway around the area seems to work pretty well. I guess it's more for multiple-pets issues but maybe she hasn't gotten used to being an only pet. I'm not sure exactly what is is or why it works, it's supposed to be like cat pheromone and calms them I guess? But it does seem to help her.
We also got her Booda boxes, with little steps to climb into the box on, it seems to be easier for her to get in & out of.
Good luck. It's a frustrating problem and I admire that you want to make it right for her. It's the only way she knows of expressing that something isn't right, but it's so hard to figure out what that something is so we can make it right for her.
2009 Trek 7.2FX WSD, brooks Champion Flyer S, commuter bike