How to create a password protected ad-hoc network on Yosemite
You can create a password-protected ad-hoc network by sharing your internet connection. To do so:


Go to Apple Menu -> System Preferences
Go to Sharing preference pane
Select "Internet Sharing"
Choose the source port
Set your connection to be broadcast over WiFi
Click on WiFi options and set a network name and security


While this is a little more involved than just creating the ad-hoc, it will serve the same purpose as well as having the benefit of sharing your connection. At this time, there is no way to add security to an ad-hoc only network on Yosemite.

Source