Sharing this because the Internet has very sketchy or conflicting info in English, and Google Maps doesn't show the below info.
All I wanted to know was whether it's doable to hike from Sintra train station up to Pena Palace and Moorish Castle. I asked at the tourist office at the train station and they recommended the Vila Sassetti hiking trail. I found that trail, with official signposts, is really too gnarly for most people of average ability (like me).
A much easier way is the Santa Maria trail, which is only half-heartedly signposted. Confusingly, there is a short route (more advertised, circular) and a long route (not well advertised, that actually gets you to Pena Palace and Moorish Castle).
You should only hike up and down from Moorish Castle and Pena Palace if you have the following:
(1) cool, dry weather (if it rains it's slippery, if it's hot it's killer),
(2) a bottle of water strapped to you on backpack or bottle holster, don't carry a tote bag, this is real hiking,
(3) proper hiking boots or shoes, sun hat, sweat towel,
(4) energy bars in case you need a boost - food options very poor at tourist attractions plus there'll be queues,
(5) hours of leisure time: i.e. you are flexible on time and have no timing constraints.
Parts of this route involve gates which might be CLOSED during off hours, so I would not start before 9 am. I did my hike at noon on very cool cloudy day which was perfect as by that time there were other hikers to follow. If you have the first timed entry to Pena Palace, you probably won't be able to make it via hiking because you might hit a closed gate before business hours. Toilets/cafes marked on any maps may not be open in real life, regardless of business hours.
In Google Maps, set your destination as "Igreja de Santa Maria, Sintra". It's a lemon-yellow, very old church. You can easily find your way to this church walking from the Centro Historico (Historic Center, the main tourist village). Finding this church is CRITICAL. If you don't start here, my below directions won't be of any use. There are MANY ways to hike up, this is the only one that worked for me, I went all the way up and down and saw Pena Palace and Moorish Castle. I wasn't trying to make any timed entry appointments. I just wanted to hike and see the beautiful forests.
Once at the yellow church of Igreja de Santa Maria, look out for yellow and red painted marks that look like = signs (2 parallel lines). They are painted on rocks and posts. They are painted = (this way), X (wrong way do not proceed), and L (turn coming up ahead).
Please BE QUIET and respectful as this is a residential area.
Sometimes you will get official signposts, but most of the time these red/yellow painted marks are your friend. If you lose track of them, don't panic. Look around patiently, they might be hidden under fallen leaves.
From Historic Center to Pena Palace (passing Moorish Castle in between - I caught a glimpse of its grounds but didn't pay to enter) it's 1 hour leisurely hike on mostly wide, paved roads. The only gnarly bits are brief: a small dirt trail in the end, and some bits that intersect with busy traffic (doable because same as walking on busy narrow streets in Lisbon).
This method is only for those who think the journey is the destination. If you dislike walking/hiking, or if your visit to Sintra is very goal-oriented ("I want to see 4 attractions in 1 day"), then you cannot do this method. I've posted this advice on Tripadvisor as well.