Yes, you can set a custom message that will be displayed to any logged- out user who tries to access locked page or BuddyPress component.
Can I Add Custom Message For Locked Component?
Update on May 25, 2022
Yes, you can set a custom message that will be displayed to any logged- out user who tries to access locked page or BuddyPress component.