I put together a simple add-on that does what you requested.
Download and install the attached .XML file, then set its settings by enabling it, defining the usergroups from which to hide profiles, and the list of usernames of those users whose profiles you wish to hide from the selected usergroups:
When someone belonging to a restricted usergroups attempts to view the profile of a hidden user, they see the following alert:
When they click the "Ok" button, they are returned to the page from which they started.
Please let me know of any changes you would like.