We went through this recently. Adopted two kittens from the shelter a year ago
and one of the cats would pee outside the litter box regularly. We did all the same thing you did to try and fix the issue. Gave it a solid 8 months or so and then finally returned him to the shelter.