For the rosws workspace each folder is whitelisted into the ROS_PACKAGE_PATH based on the .rosinstall file. If you remove an entry from the .rosinstall file, and then share it with someone, they can run rosws regenerate to get new setup.*sh files which will not add the removed entry's folder to the ROS_PACKAGE_PATH.
For catkin, you'll have to rm -rf the folder or touch src/pkg_to_ignore/CATKIN_IGNORE.