A Senate hearing spotlighted the defense secretary’s decision to share sensitive information on a messenger app generally not authorized for government communications.