Do you want users without permission are able to view the name of the SharePoint library and are redirected to the access denied page when they click the library name?
If that is the case, you could add a link named library name linked to the library in Quick Launch or Left Navigation in SharePoint. Then users view the name of the library and it displays error page when they click on the link.
If the library is a web part in the page, you could create a custom link in this page.
A post about how to add links in Quick Launch or Left Navigation for your reference:
If it doesnt work, please provide a screen shot about the error and provide more details about Correlation ID in ULS logs.
An even better way to get the real SharePoint error from the ULS logs: