Train is not possible. At present there is only one train per day from Madrid to Lisbon which runs via Vila Formoso.
Bus is also not really an option for a same day trip as you would have to go via Lisbon.
Have a look at this recent post on my blog:
http://barlaventostravelblog.blogspot.com/2008/05/travel-from-madrid-to-castelo-branco.html
Hire Car is your only option to do it the same day, but be aware that inter-country drop-offs in Europe are very expensive. You would probably have to drop the vehicle off in Spain afterwards.
Madrid Barajas Airport to Castelo Branco by road is approximately 409 km – about 5 hours drive.
I have created a google maps gazeteer here:
http://maps.google.com/maps?f=d&hl=en&geocode=&saddr=Madrid,+Barajas,+Spain&daddr=Castelo+Branco,+Portugal&sll=37.15781,-8.734502&sspn=0.24571,0.601501&ie=UTF8&t=h&z=8