A rash appears on my baby's scalp every time we go out. Could it be from the sun?

I hope not. Hopefully you keep your baby covered when out in the sun. If you do it might be a heat rash as the heat increases the blood supply and the activity of the sweat glands either of which can aggrevate an existing rash or cause a new pimply rash.
Maybe. To see if sunshine is causing a rash on the scalp, just compare the appearance of the scalp after outings where the baby wears a hat, with the appearance after outings where the baby doesn't wear a hat. Babies have sensitive skin which can turn red and sunburn after just a short while in strong sunlight.