I think most of my countries would do it in a similar manner…an adoptive family, orphanage worker, or other care-taker would name them, and that’s what they would go by. Some may never have surnames, and some would just take the ones of the people they were in the care of.
Unfortunately, in some cultures, they probably don’t take care of abandoned kids at all.
I haven’t really run into this problem…one of my MC’s is just a kid when he comes as a slave to a new place, but he remembers his name (he’s 4 or 5). Another OC was just named one name, his dad’s last name, Jamison, and left with that.
I guess having a surname depends on the culture…whether it’s an important component to a cultural identity or not.
Not all those who wander are lost.