What is the best way to secure my MacBook Pro from hackers when I'm logged into public Wi-Fi
There are a few measures you can take. Let's start with over-sharing.
By this I mean that if you don't want to provide people access to your Mac, you should shut any doors that provide it. To start, go to System Preferences > Sharing and turn off any sharing options you have enabled--file sharing and screen sharing, for example.
Although it doesn't provide a way into all of your stuff, you may also wish to turn off iTunes sharing. On more than one occasion I've logged onto a hotel network, fired up iTunes, and found a load of shared iTunes libraries--some identified by the user's name. This can be particularly embarrassing when you know that person and their library is full of 70s disco albums. (That kind of insight, no one needs.) To switch off sharing, open iTunes' preferences, click the Sharing tab, and uncheck Share My Library On My Local Network.
Of course if you're really concerned, you could also turn off Wi-Fi altogether when you're not using it, which would certainly bar any attempts at your stuff when you're not watching your computer.
That's all well and good in regard to keeping out intruders, but what about the data you're sending over the network If you're looking for that kind of protection, consider paying for a VPN (Virtual Private Network) account. Log into a VPN and your data is encrypted as it passes through a secure tunnel, thus keeping the good stuff out of the bad guy's clutches. If you're interested in learning more, see Glenn Fleishman's How to surf safely with a VPN-for-hire.
Or you could forego this Wi-Fi connection entirely and instead use another hotspot. Your iPhone could be just the thing if you've paid for a tethering plan. Yosemite's Instant Hotspot feature makes this really easy. Your iPhone will appear under the Mac's Wi-Fi menu if the phone's running iOS 8 and you have a tethering plan. Just choose it and you're good to go.
And then there's the old-fashioned way. Purchase a MiFi device from just about any mobile carrier along with a data plan to feed it and you have a hotspot in your pocket.