The tutorial Exclude a country shows that excluding countries works also when there is a considerable detour, but there are limits to what the route calculation can handle. For example, a route from Berlin to Vilnius while avoiding Poland will fail the calculation.
curl -X GET \ 'https://router.hereapi.com/v8/routes?origin=52.494438,13.40415&destination=54.679577,25.254137&return=polyline,summary,actions,instructions&transportMode=car&exclude[countries]=POL'
Even though there are limits to this functionality, we believe all real-life use cases are supported. For a request with a successful detour calculation, see Exclude countries.