Praise be to Allah, the Lord of the Worlds; and blessings and peace be upon our Prophet Muhammad and upon all his Family and Companions.
If you enter the mosque while the Imam is delivering the Khutba (Friday prayer sermon), pray two Rakaas quickly as a greeting to the mosque and then sit down. The evidence for this is the Hadith reported by Muslim and narrated from Jaber Ibn Abdullah who said: "Sulayk Al Ghatafany entered the mosque on Friday while the Prophet was delivering Khutba then he sat down. The Prophet said: "O! Sulayk stand up and pray two Rakaa's and do not read much in them". Then he (the Prophet) said: "If any of you comes to the mosque on Friday while the Imam is delivering the Khutba, he prays two Rakaas without lengthening them".
Allah knows best.