At least in the army by New York State
In a good article on the soldiers’ vote Mr. Lincoln and New York explains that New Yorkers overwhelmingly approved a constitutional amendment in the spring of 1864 allowing troops to vote in the field. According to the following, the state legislature tried to guard against officers coercing their men to vote a certain way. The Democrat paper wanted to make sure soldiers knew they were free to vote for General McClellan for president.
From a Seneca County, New York newspaper in October 1864:
Attention, Soldiers!
The laws of this State provide that if
SEC.13. Any officer of this State or of the United States, who shall, directly or indirectly, control or attempt to control any such enlisted elector in the exercise of any of his rights under this act by menace, bribery, fear of punishment, hope of reward, or any other corrupt or arbitrary measure or resort whatever, or to annoy, injure, or otherwise punish any such officer or man, for the manner in which he may have exercised any such right, shall be deemed guilty of an offense against the sovereignty of this state, which shall be punished as a misdemeanor, and for which he may be indicted and tried at any future time, when he may be found within the limits of this state; and upon conviction he shall be imprisoned for a term not exceeding one year, and fined in a sum not exceeding one thousand dollars and he shall also thenceforth be ineligible, after conviction thereof, to hold any office in this state.
Under the provisions of this act, any Colonel, Captain, or other military officer, high or low, who shall in any way, improperly influence or annoy, or attempt to annoy, any private soldier desiring to vote for McClellan, is liable to indictment and punishment as a felon, in this State. We therefore urge our boys to make complaint wherever they are abused or intimidated. They can send their complaints to any Grand Jury, and they will be entertained. there is no statute of limitations in this case, and there are some counties where courts will do their duty.
You can read about the following anti-Republican political cartoon at the Library of Congress: