It is hard to provide a definitive age, as it is very much dependent on the child, their maturity and a number of factors that I have already enumerated in the comments above.
That being said, by way of introduction, I am reminded of the Rambam in Hilchos De'os 6:1 which says expressly:
דֶרֶךְ בְּרִיָּתוֹ שֶׁל אָדָם לִהְיוֹת נִמְשָׁךְ בְּדֵעוֹתָיו וּבְמַעֲשָׂיו אַחַר רֵעָיו וַחֲבֵרָיו וְנוֹהֵג כְּמִנְהַג אַנְשֵׁי מְדִינָתוֹ
It is natural for a man's character and actions to be influenced by his friends and associates and for him to follow the local norms of behavior.
Indeed, this is no different with children. A good friend can withstand the test of time and a true friend can have a major impact on that person's life (see Avos D'Rabbi Nosson 8:3)
Most parents will send their children to a school that is aligned to their hashkofo and worldview, and by extension, will hopefully ensure that their children are surrounded by kids of other like-minded parents. Therefore, this presents (although not foolproof) the opportunity to hopefully create good, positive friendships that will overtime, form a "chevra" that will help to frame and impact their child's behaviour and outlook. The obvious flipside to this is that if the chevra are disingenuous, and of a bad influence, it will impact negatively.
So, we see that friends can be a very powerful influence when they are right for the child.
Rav Wolbe in Alei Shiur, Cheilek 1, shaar rishon, perek 4, has a whole piece entitled "chevra". There he starts with exactly the point I make:
להיות בין חברים אשר שאיפה אחת להם, חויה אחת משלהבת אותם, איש עוזר לרעהו בעבודה היום-יומית ולאחיו יאמר חזק ברגעים של רפיון וחלישות-הדעת - זוהי משאת-נפשו של כל אדם, ובפרט כל צעיר
To be among friends who have the same ambition, one experience that inflames them, each person helps the other in their daily work and speaks loudly to their brother in moments of laxity and weakness of mind - this is the desire of every person, especially every young person.
So, when done well, it is an amazing thing.
A final introductory point as to why friendship and the power of a social circle should be encouraged from an early age is the establishing of a relationship that when positive, is a good lens for the child to view their relationship with G-d.
Rav Moshe Chaim Schlanger shlita, a well-known mechanech in Eretz Yisroel (and a principal talmid of Rav Moshe Shapiro zt"l) in his phenomenal sefer, Ohel Yaakov V'Leah p. 193 writes:
הנאמנות לחבירו היא היסוד שעליו עומדים כל משפטי בני אדם. ומידת הנאמנות כלפי הקב"ה וכלפי חבירו אחת היא. מי שאינו נאמן לחבירו, יש להניח שלא יעמוד בנאמנות כלפי השי"ת
Loyalty to one's friend is the foundation on which all human judgments stand. And the degree of loyalty to G-d and to one's friend is the same. He who is not loyal to his friend, it must be assumed that he will not be loyal to G-d, blessed be He.
Let's now discuss the technicalities - the how and when...
As mentioned, each child is different and has different maturity levels. That being said, Rav Wolbe in his masterful sefer on chinuch - Zeriyah Ubinyan B'Chinuch p.13-16 speaks of a "נקודת ההתחלה" a "starting point" by which a child is able to understand/internalise to some degree, the ideas that a parent conveys to them. He writes there (p.14):
הדברים הללו הם היסוד של "נקודת ההתחלה", רגע הזריעה, התחלת החינוך לשלביו השונים. רש"י בפרשת "לך לך" כותב לגבי אברהם אבינו, על הפסוק "וירק את חניכיו" (בראשית יד:יד): חינוך הוא לשון התחלת כניסת האדם או כלי לאומנות שהוא עתיד לעמוד בה. חנוך לנער, חנוכת המזבח, חנוכת הבית
עניינו של חינוך לפי רש"י הוא הכניסה הנכונה בנקודת ההתחלה. זהו חנוך לנער. כשהילד מגיע למצב מסויים, צריכים לזרוע בו מה שהוא מוכן לקלוט באותו זמן
These words are the basis of the "starting point", the moment of sowing, the beginning of education in its various stages. Rashi in parasha Lech Lecha writes about Avraham our father, on the verse "And he trained his students" (Bereishit 14:14): "The word חנך signifies introducing a person or a thing, for the first time, to some particular occupation in which it is intended that he should remain (i. e. to dedicate or devote to some particular purpose). It has a similar sense in (Mishlei 22:6) “Train up (חנוך) a child”, and in (Bamidbar 7:84) חנוכת המזבח “the dedication of the altar”, and (Tehillim 30:1) “The dedication (חנוכת) of the house”
The matter of chinuch according to Rashi is the right entrance at the starting point. This is "train the child". When the child reaches a suitable state, one should sow in him what he is ready to absorb at that time.
In other words, at least in this context, a meaningful friendship, as discussed above would begin when the child is able to take and gain something from it. This is not so say that an earlier age of socialising is not worthwhile (indeed from a developmental perspective one can argue through social gatherings, a toddler acquires social skills, develops empathy and creates communication with the environment), but when a child is more cognisant of the world around them it definitely makes for a more substantial companionship.
I can't point you to any immediate Jewish source about the developmental nature of nurturing friendships from a young age, but I can point you to the acclaimed Jewish psychotherapist and family counselor - Dr Meir Wikler. He is also the author of, Partners With Hashem: Effective Guidelines for Successful Parenting (Artscroll/Mesorah, 2000)
He has a piece on Aish.com here entitled, "Making Friends". He writes there why friendships are so foundational in younger children, specifically once they enter schooling:
While your child is an infant and toddler, friendships are very irrelevant and insignificant to him. His entire focus is on you, your spouse and his siblings. Your family makes up his entire social world.
Once your child enters preschool, however, he enters an alien, competitive and sometimes hostile social universe. In order to survive, he must succeed at making friends.
Without friends, your child lacks partners for games and play, companionship during free time and, most importantly, allies for protection against bullies and other aggressors. Without friends, your child feels alone and is alone. Not having friends undermines your child's self-esteem and erodes his confidence. It heightens his insecurities and fears. And it may make him want to avoid camp, extracurricular activities and even school itself.
When young children who are at this stage in life have friends, it creates the opportunity to make lasting lessons. They learn how to look out for a friend, to gain a sense of happiness when helping them and enjoying their company.
So why is it important to teach children the means to socialise...
We know from Parshas Noach (Bereishis 8:21):
כִּ֠י יֵ֣צֶר לֵ֧ב הָאָדָ֛ם רַ֖ע מִנְּעֻרָ֑יו
That the desire of a man’s heart is evil from its youth
HaRav Ben Zion Abba Shaul zt"l, explains that a person has bad middos that are innately rooted from birth. If it were not for the fact that we receive chinuch as youngsters, these bad traits would further intensify as we mature. (See Ohr LeTzion, Shaar ben adam lechaveiro, maamar 6 - chinuch habanim p. 188)
The challenge of parenting is to provide each child with what they need so that they can develop a better understanding of the world, remove the innate selfishness that comes from being born as a "taker" and build meaningful relationships that will help them reach their potential.
Rabbi Abraham Twersky in his sefer, Positive Parenting p.48 writes:
As a child grows and begins to change from the totally self-centered infant to a youngster who must interact with others. situations arise which the young child does not yet know how to handle. For example, the child has candy or toys, and his infantile tendency is to keep them for himself. If he is to become a social being, he must learn how to give and share. Or perhaps someone else has something which the child desires. The young child does not know right from wrong, and he might try to take it away from another child. This is incompatible with living in society. The parents must begin to teach the child basic social skills.
So, fostering friendships, developing their social skills, is the means through which a child learns to become a giving, more loving human being.