Unfortunately Facebook Chat doesn’t have this feature but you can use Facebook’s Friend Lists feature to set who can see you when you’re online.
When you pop open the chat window, you can find all your friends who are currently signed into chat. If you have created any friend list, they will appear under that list. All your lists can be viewed by clicking on Friend Lists at the top.
Now, to hide yourself from specific users, go to your Facebook home page, click on Friends on the left panel or else go to Edit Friends from the Accounts tab found at the top right corner of all pages.
All your Facebook friends will be listed on this page. On the upper right of the page is a button, “+ Create a List.” Click that. Facebook will pop up a box as you see below, that lets you create a new list by selecting the users you want. Give a name to the list, for example Hide on Chat and select the users to whom you don’t want to appear online. Once selected click the Create List button to save it.
After that, go back to the Chat window and click Go Offline, then back Go Online. Your new list will appear, with your selected friends if they are online. To the right of its name there’s an icon that looks like a toggle switch. Mouse over it, and label will pop up that says Go Offline. Click the toggle and Facebook will hide you from the friends on your Hide on Chat list.
Friend lists can also be sorted. To do so, click on Options and then Re-Order Lists. This will hide your friends and show you all your friend lists. You can just drag and drop them in the order you want.
Note: If you have a friend on two lists, one of which is set to online and the other set to offline, Facebook will make you online for that friend. To hide from them, you’ll need to either remove them from any lists you make visible, or to turn those other lists off as well.