Can htpasswd be used to restrict access to a URL rather than a specific folder?

From the docs:

Require Directive

Description:  Selects which authenticated users can access a resource
Syntax:       Require entity-name [entity-name] ...
Context:      directory, .htaccess
Override:     AuthConfig
Status:       Core
Module:       core

"directory" context means that you can put it in <Directory>, <Location>, <Files>, and <Proxy> sections. So, yes.