Praise be to Allah.
The correct scholarly view is that he should say the salaam with the imam, because then he has followed the Sunnah by shortening his prayer, and he has not gone differ from the imam, because the imam prayed two rak’ahs.
The traveller is only enjoined to offer the prayer in full with four rak’ahs if the imam is praying four rak’ahs, so that he will not be differing from him. Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) was asked: I entered al-Masjid al-Haraam to pray ‘Isha’ and I found him praying Taraweeh. Should I pray Taraweeh with the intention of ‘Isha’, or should I pray ‘Isha’?
He replied: If a person enters the mosque and the people are praying Taraweeh, and he has not prayed ‘Isha’ yet, then he should join them with the intention of praying ‘Isha’, then if he is travelling and he joined the imam in the first rak’ah, he can say the salaam with the imam, because the traveller prays two rak’ahs. If he is a resident, then when the imam says the salaam he should complete whatever he still has to do of the four rak’ahs. Someone may say: How can he offer an obligatory prayer behind someone who is offering a naafil prayer? But this happened at the time of the Prophet (peace and blessings of Allaah be upon him), as Mu’aadh ibn Jabal (may Allaah be pleased with him) used to pray ‘Isha’ with the Prophet (peace and blessings of Allaah be upon him), then he would go to his own people and lead them in the same prayer – it was naafil for him and obligatory for them. Even if there is someone with him, it is better for them not to be separate from the other Muslims; it is better for them to pray with the Muslims and intend their prayer to be the obligatory one. End quote from Liqa’ al-Baab il-Maftooh (30/117).
And Allaah knows best.