The procedure is now essentially the same as done at airports. All checked luggage is x-rayed and they also have drug and explosive detection dogs working. You can lock it, but bear in mind if they find anything that looks suspicious and they can't open it, your luggage will be held by security and you will be summoned to open it in their presence. The typical reason is they see evidence of an attempt to sneak alcohol aboard. This is especially true for Royal Caribbean and Carnival ships.
Most experienced cruisers do not put anything valuable in the checked luggage and instead put it in your carry-on bag(s). Carry-on bags are checked with an x-ray machine too, just like at the airport. You have to clear a metal detector too. This is also done at every port when you return to the ship. Purses, fanny packs, purchases you made ashore, all get screened. In some ports the local police will also check them. This is especially true in places like Jamaica and Mexico where they are specifically looking for drugs.