When a suit or proceeding shall be commenced in any court by any person, against any military officer of the state, for any act done by such officer in his official capacity in the discharge of any duty under this article, or against any person acting under the authority or order of any such officer, or by virtue of any warrant issued by him pursuant to law, the court shall, upon motion of the defendant, when it has been made to appear to the court by affidavit, or otherwise, that the act done is such as hereinbefore set forth, require the person prosecuting or instituting the suit or proceeding to file security for the payment of costs that may be incurred by the defendant therein. This security shall be by bond payable to the state, with surety to be approved by the clerk of the court, in a penalty equal to six times the costs incurred and likely to be incurred by the defendant, but in no case shall such bond be for a penalty less than $500. The court before whose clerk such bond is given, may, on motion by a defendant, give judgment for so much as he is entitled to by virtue of such bond under the provisions of this section. If such security for costs be not given within sixty days from the time the same is required by the court to be given, the suit or proceeding shall, by order of the court, be dismissed. In case any suit or proceeding shall be dismissed for failure to give security for costs, then the defendant shall recover three times the amount of the costs incurred by him In all such cases as are referred to in this section the defendant may make a general denial and give the special matter in evidence.