Do you mean before you build the workspace or after it is installed and you've sourced the setup file?
In the former case you have to ask colcon
with something like this:
% colcon list | grep rviz
rviz2 /Users/william/ros2_ws/src/ros2/rviz/rviz2 (ros.ament_cmake)
rviz_assimp_vendor /Users/william/ros2_ws/src/ros2/rviz/rviz_assimp_vendor (ros.ament_cmake)
rviz_common /Users/william/ros2_ws/src/ros2/rviz/rviz_common (ros.ament_cmake)
rviz_default_plugins /Users/william/ros2_ws/src/ros2/rviz/rviz_default_plugins (ros.ament_cmake)
rviz_ogre_vendor /Users/william/ros2_ws/src/ros2/rviz/rviz_ogre_vendor (ros.ament_cmake)
rviz_rendering /Users/william/ros2_ws/src/ros2/rviz/rviz_rendering (ros.ament_cmake)
rviz_rendering_tests /Users/william/ros2_ws/src/ros2/rviz/rviz_rendering_tests (ros.ament_cmake)
rviz_visual_testing_framework /Users/william/ros2_ws/src/ros2/rviz/rviz_visual_testing_framework (ros.ament_cmake)
For the latter there is ros2 pkg ...
commands, e.g.:
% ros2 pkg list | grep rmw
rmw
rmw_connext_cpp
rmw_connext_shared_cpp
rmw_fastrtps_cpp
rmw_fastrtps_dynamic_cpp
rmw_fastrtps_shared_cpp
rmw_implementation
rmw_implementation_cmake
rmw_opensplice_cpp
Or this:
% ros2 pkg prefix rclcpp
/Users/william/ros2_ws/install/rclcpp
If you're looking for something to do the grep for you, then we'd have to add a verb for that, but I think it would probably be accepted if a pr was made to that effect (after some iteration probably).