This is a question that comes up a lot in the masajid. The following answer is from en.islamtoday.net which is a website supervised by Shaykh Salman al-Auda. Original article here.
Therefore, we say that it is better to wait and start a new congregation with other latecomers to the mosque instead of making indications to people who are busy finishing their prayers that you want them to act as your imam.
However, in the event of someone doing so, it is permissible for the person being followed to change his intention from that of praying on his own to that of being an imam for others, since it is generally permissible for a person to change his intention in this way.
The evidence for this is that the Prophet (peace be upon him) was once praying alone at night, then Ibn `Abbâs came and joined him in prayer. The Prophet (peace be upon him) completed his prayer leading Ibn `Abbâs. [Sahîh al-Bukhârî (883) and Sahîh Muslim (763)]
And Allah knows best.