How to deny access to SQL Server to certain login over SSMS, but allow over .Net SqlClient Data Provider
I think there is no reliable solution for your problem since Application Name is modifiable parameter that cam be changed by any user.

Here is how to change it within SSMS:

In Connect to Database Object dialog choose Options, open  Additional Connection Parameters and choose any name for Application Name like this:



Now sys.dm_exec_sessions DMV and Program_name() will show you what you passed in your connection string in Application Name parameter: