If he's with friends though, or he's far enough away from me that I'd have to walk over to him - wondering if a smile and a wave would suffice, or if that would seem cowardly.
Another good question to ask and, fortunately, the answer is within your power!
You can think about what
you want. Do you even want to engage with him? If not, there's no requirement "for politeness" or for any reason that you have to cross the street to talk to him. You can have integrity in that moment of maybe seeing him across the street, smiling and waving, and keeping on walking. That leave the ball in his court, so to speak. You can also plan ahead -- if he responds to the smile and wave and comes towards you, you can decide now what you would want to do. If not, you can rest assured that you did a pleasant and normal acknowledgement and moved on with your day. You aren't going to "make a mean face" at him or snub him. Smiling, waving, and continuing on is super normal.
It's up to you and your goals/integrity what a smile and wave would mean. There's no inherent rule that it means you're weak or cowardly for not wanting to engage with him. After all, you're in that town for a completely different reason, right?
there's still a part of me that clings to a fantasy of him apologising to me one day. I know that's unlikely, and anyway, I would not expect it from a random encounter in public – I would want to leave as quickly as possible.
Yes, that's good to do some cognitive assessment of the reality of running into him in public. Part of you hopes/dreams for closure, yet you are able to rationally examine what would likely happen, and not pin unrealistic hopes on "one magical encounter".
Have you ever heard of the acronym "BIFF"? It stands for Brief, Informative, Friendly, and Firm. I think there may be a link on the site to an article; if not, a Google search for BIFF can give you some more info. It's one approach to dealing with disordered people in a way that is effective, not unkind, and lets you hold on to your integrity. Worth a look.