Yes, command authorization codes can be changed by the ship's command officers. In the case of crew missions with command officers, they are likely to be changed fairly regularly because if a command officer is lost, there is the potential of them falling into the wrong hands puts the ship systems under that officer in jeopardy.
Star Trek does not go into specifics about command codes and how they are used so we are always forced to extrapolate exactly what is possible in their use. We have seen with the right command codes you can disable shields, weapons, in some cases all vital command functions of a starship can be disabled or taken control of.
Command codes are also linked to another feature of security onboard starships called security clearances.
Security clearance or security verification is a level of authority given to an officer based on rank, status and position. Computers then identify the individuals by the entry of their vocal or numerical authorization code. Alternatively, specially programmed isolinear rods entered into the computer can also allow various levels of security clearance. (DS9: "Babel", "The Passenger", "Vortex")
Memory Alpha also indicates:
The command authorization code (or simply authorization code) was an alphanumeric sequence used by militaries and civilian agencies to allow access to certain command protocols and restricted information. These codes were also known as a voice authorization code, security code, command code, access code, or simply password.
Some of the many uses of authorization codes including: activating and canceling auto-destruct sequences, transferring of command of a starship, accessing secured locations, and ejecting a warp core. (Star Trek: First Contact; VOY: "Deadlock", "Dreadnought", "Cathexis", "Renaissance Man"; TNG: "Chain of Command, Part I")
In an ideal setting, the command codes would be issued from a centralized location, like Star Fleet Command, and changed regularly, but in the case of ships on long deployment, it is possible their local computer systems will create new authorization codes as needed.
It is possible the authorization code system can be hacked because, at least theoretically, we have normally seen command overrides to require voice analysis and a correct command code to be able to use the systems. We have seen command codes being used without voice input bypassing the vocal biometric safeguards. Kirk does this against the Reliant, dropping their shields. This is an example of an inelegant hack, or a use of a command-level code which does not require biometric, secondary authentication.
In an ideal Federation, the ships systems would be broken down into a layered command structure where certain controls can be accessed by their properly coded officer and the particular officer's abilities are limited to his sphere of technical or operational influence.
This would mean:
Systems such as the automated self-destruct which normally requires three command level officers to make the decision and authorize it would remain beyond the ability of any single officer to authorize unless an override is utilized. (This may be the case for the Captain of a starship in case of crew debilitation and the ship is about to fall into enemy hands, for example.)
Operation command of multiple vital systems such as a transfer of ship control to a secondary bridge or engineering should require a command level authorization and verification from the ships computer since routing of commands will need to be configured by both the ship and the crew. Such a command is probably limited to high ranking officers Lt Commander and above (unless authorized, since smaller ships may not have as many high ranking officers.)
The Captain's personal command code would allow them control of any singular system, even if they were not normally responsible for that system. Such a command code would be vital since it could be used to override any system without extra security being used. In the case of a rogue use of such a command, the ranking officers would likely have to collectively disable the use of the captain's command codes and would have to log this officially before the computer system would comply.
The First Officer would likely have a similar control protocol as the Captain since he/she would potentially be in the same position as the captain if they needed to take control of that system.
Operational Lead Officers such as the Science Officer, would have access to labs, science stations and other sensor technology but not have access to bridge, control or engineering functions without a corresponding computer override or technical code from a local staff member.
Department Heads would control the technology within their sphere of influence and little else except technology which would remain open to all other crew members. So an engineering department head might have access to the EPS power manifold systems because this was part of the engineering control system, but he would not have access to a particular science lab without authorization from the Science department. This means systems like the transporters are normally locked out from regular crew members without the proper authority or rank structure.
Unfortunately, Star Trek, while claiming to adhere to a structure similar to this one, will often do something different for the sake of dramatic license.