The ex-president of Costa Rica has compared Donald Trump's behaviour with that of a Roman emperor.