You MIGHT be able to do it with script. Google is quite good at executing scripts before processing the page.
However I’m struggling to understand this situation, it sounds like you’d be better off with a redirect or perhaps an hreflang link. Otherwise… why would you want more than one page to have the same canonical?