My rear disk brake doesn't lock in place. Don't know whether hydraulic or mechanical
You mention the brake is brand new.

Have you "bedded" the pads in?
Bedding involves riding down a hill and feathering the brake lightly.

The other possibility is pad / disc contamination. In particular oil.
Discs can be cleaned with appropriate solvent.
Pads can be cleaned by baking (faced down) on grease proof paper or gently heating over a flame to burn off the residue.