It is possible but difficult. Spray all primer first then the ceilings. Masking is problematic at best. If you allow the ceiling paint to dry overnight you can mask with 12 inch paper or 2 foot plastic film.
It is also possible to shield the ceiling while spraying the walls. In this case you would want to use cardboard shields with a holder attached to a roller pole. This is a 2 person job but very doable if your skills with a sprayer are good.
In both cases there will be some touch-up and possible cutting-in where the ceiling meets the walls. It all depends on the masking and the texture you are dealing with.