It seems that this function supports only decryption of password protected archives (see changelog: http://pecl.php.net/package-changelog.php?package=zip). Creation of password protected archives is not supported (they will be created simply as non-protected archives).
Example code for extraction of files from password protected ZIP archives:
$zip = new ZipArchive();
$zip_status = $zip->open("test.zip");
if ($zip_status === true)
echo "Extraction failed (wrong password?)";
die("Failed opening archive: ". @$zip->getStatusString() . " (code: ". $zip_status .")");