The first one to surrender (on screen) was the Lannister Captain that was facing down Jon, Grey Worm, a street full of Unsullied and Northmen, and a rather angry looking dragon on the tower.
Once someone with a position of authority set the precedent of surrender, the cry to "ring the bells!" spread through the army. We don't see who first uttered the cry, but we can safely assume it was the captain (or a lieutenant nearby) calling out to signal that the city surrendered.
Ringing the bells was apparently a culturally known sign, and since it was something a city's people would do, instead of something requiring the Lord/Lady/General to do (like a parley), it would seem it was somewhat common. This would make sense in a world where random towns would be used to various armies "conquering" them regularly. Like Tyrion said:
What is the realm? A vast continent, home to millions of people, most of whom don't care who sits on the Iron Throne.
Game of Thrones - S08E04: Last of the Starks
The random citizens would rather pay taxes to the next Lord over, than die in defense of their current one. So once the army started surrendering, they raised the cry to "ring the bells!" and signal the surrender so that no one else had to die from the massive dragon who was actively burning down their city.
In short, and to answer the question directly, it was a general consensus based on cultural norm and prompted by the Lannister Captain who realized he was going to lose his battle.