Any person subject to this chapter who, in the presence of a court-martial, a board of officers, a military commission, a court of inquiry, a preliminary hearing, or an officer taking a deposition, of or for the United States, wrongfully refuses to qualify as a witness or to answer a question after having been directed to do so by the person presiding shall be punished as a court-martial may direct.