The story in question is described in Saint John of Damascus' writings, which I will quote here:
Then there is the book of The Camel of God. About this camel [Muhammad] says that there was a camel from God and that she drank the whole river and could not pass through two mountains, because there was not room enough. There were people in that place, he says, and they used to drink the water on one day, while the camel would drink it on the next. Moreover, by drinking the water she furnished them with nourishment, because she supplied them with milk instead of water. Then, because these men were evil, they rose up, he says, and killed the camel. However, she had an offspring, a little camel, which, he says, when the mother had been done away with, called upon God and God took it to Himself.
This story is not in the Qur'an, but it appears to be referencing the camel that the prophet Salih presented to the people of Thamud as a sign of Allah:
- You are but a man like ourselves, so bring a sign, if you should be of the truthful."
- He said, "This is a she-camel. For her is a [time of] drink, and for you is a [time of] drink, [each] on a known day.
- And do not touch her with harm, lest you be seized by the punishment of a terrible day."
- But they hamstrung her and so became regretful.
I don't know where the extra details came from, but it was not uncommon for the lives of the previous prophets to be compiled into such stories and propagated, based on any number of sources both authentic and dubious, including stories and legends from the Israiliyyat and Jahiliyyat.
I think it's important to note that John of Damascus lived about a century before Muhammad al-Bukhari compiled his famous Sahih and modern hadith sciences were born. Outside of the Qur'an itself, anything that claimed to be the direct words of Muhammad should probably be taken with a grain of salt.