
Recommendations for software (and Linux software at that) are off-topic, but: password-protected encryption is part of the PDF standard, so any Linux PDF-compliant app should be able to create a PDF that requires a password to open it.
On MacOS, Apple’s built-in Preview app can open encrypted PDFs, if the password is entered.
For other file formats, zip encryption with a password may be a good option.