Hello Rival,
As Conscious thoughts and Salix said above, our personality is part of the soul, and
not part of the brain.
Let me explain this in my own words. (It is based on my own observations and also on what the Hindus believe).
The Universal Consciousness or Brahman (which we really are) resides in three houses - the physical body, the subtle body and the causal body.
We're all aware of our physical bodies.
The subtle body, on the other hand, contains memories, desires, dispositions, personalities, intelligence, ego etc.
In short, the subtle body, is a kind of subtle mind. It exists and functions, even after the death of the physical body.
Then comes the causal body. It contains all the karmic records as Salix said above. After the death of the physical vessel,
the subtle and causal bodies (together known as the Jiva/soul) continues to exist and function, which then transmigrates and finds a fresh physical body.
============
Now, coming back to your question,
Is personality a result of one's brain function?
Well, not really.
IMO, personality is the result of the info we gather from the outside world. And it is not the brain which recieves these infos. The brain simply processes the infos and commands the body how to act. Then who gathers the infos? ... The sense organs.
It is true that an injury to the brain (from a car crash or drug abuse) results in physical and mental illnesses, including changes in mood, personality and behaviour. But such a thing happens only because the three bodies are kind of connected to each other (as long as we are in a human or animal form).
If there occurs a change in any one of these bodies, the effect will be felt by the other two bodies as well.
For example, if you recieve a blow on your physical body (head/brain) then your behaviour or personality (which is part of the subtle body) will surely change.
Similarly, when we recieve information from the outside world, they are stored right away in the warehouse of our subtle body.
Certain change in the amount & type of information in our subtle body's warehouse, results in new behaviours and actions, which are then felt by both the subtle and physical bodies.
Same thing goes for causal body as well.
When new (good & bad) karmas are stored in the warehouse of our causal bodies, the changes in the amount & type of karmas, in the causal body, decides the reward or punishment that the subtle and physical bodies will recieve in the future.
=============
Your second question was -
We can observe babies' different personalities, though, pretty much from birth. What would you say shapes these if habit hasn't had time to form?
Again as per Hinduism, a baby's personality (from its birth) are shaped by its previous lives' accumulated information, knowledge, dispositions, memories, desires etc. (that are being stored in the warehouse of subtle body) and by its previous lives' accumulated karma (which are stored in the warehouse of causal body)
... These stored data from previous lives actually shapes our personalities according to Hinduism.
That's why sometimes you'll get to hear in the news that a 4 year old is playing piano like a pro adult