This is what we are going through with our ancient rescue mutt.
Around two months ago he really started behaving differently. He had started wetting himself on the sofa, sometimes standing and doing it (we've learnt not to leave anything valuable or any clean laundry etc on the sofa not) other times he has laid there, I've had him checked for a UTI but even with the extensive test nothing showed up. He saw the vet yesterday, we are trying an antibiotic in case he has something like Cushings and a UTI isn't showing up.
He has become real snarky and aggressive, he also whines and cries and we don't know why. The snapping is so out of character, he seems to have lost his ability to restrain himself from going for our food. He started getting up in the night which he hasn't done since we first rescued him. He also paces and doesn't relax in the day.
Today we tried to take him for a walk, but I had to pick him up and put him inside my hoodie. We abandoned the walk. He has been shaking more, and even the way he cuddles me has changed.
He's also seeking out my partner to sleep on or next to, he was never really into anyone else but me. Which seemed a pain until he didn't want me as much anymore.
Total personality transplant. It's really been making things hard at home and it's been worrying that he could actually harm someone if he gets cranky enough.
So the vet said if he doesn't respond to these pills, and a bloodtest doesn't show up something curable, then we have the option to say goodbye to him while he still has enough of his faculties left to know who we are and to feel loved and comforted and so on. I don't want to keep him going unecessarily past the point of comfort (he already sounds like he is in pain).
OP, I hope there was a curable reason why your dog has been off. This is a horrid feeling and I don't wish it on anyone.