Yes, though they break down slowly and are best used as a modest fraction of a pile. The widespread belief that they will acidify your compost is largely unfounded. The acidity is mostly gone by the time they have decomposed. Below: whether you can compost pine needles, why, how much to add, and the mistakes that cause trouble.
Adding pine needles to a pile. Chop it, mix it, bury it.
Why
Pine needles are waxy, resinous and structurally tough, which is why they resist decomposition. They are a brown, roughly 80:1.
Fresh needles are acidic, around pH 3.5. Finished compost containing them tests close to neutral, because decomposition itself buffers the pH.
How to add it
Shred if possible, keep them to maybe a tenth of the pile, and expect them to take a year or more.
They are more useful as a mulch, where their slow breakdown and interlocking shape are advantages rather than problems.
Common mistakes
Adding a thick mat of needles, which sheds water like a thatched roof.
Using them to deliberately acidify soil for blueberries. It does not work to any useful degree.