Overview
I created a custom REST resource by following the instructions below.
https://www.drupal.org/docs/drupal-apis/restful-web-services-api/custom-rest-resources
By following the above article, I was able to obtain a JSON result from the following URL.
/demo_rest_api/demo_resource
REST UI Module
The above article included the following note:
If you are using the REST UI contrib module, you should now be able to see it in the list of available endpoints and you should be able to configure the GET method.
For this, I enabled the REST UI module by referring to the following article.
https://www.studio-umi.jp/blog/12/357
Prototyping the IIIF Presentation API
Next, I worked on creating JSON for each content item. Specifically, I configured it so that accessing the path /iiif/3/{id}/manifest would output information based on the IIIF Presentation API v3.
The following article was helpful.
Create a file as follows. In this example, the title is retrieved from $node. By extending this approach, information from other fields can also be retrieved.
Granting Permissions
On the following page, check the box for Anonymous user to allow access from external sources.
/admin/people/permissions#module-rest

As a result, by accessing a URL like /iiif/3/5070/manifest, even non-logged-in users can retrieve a JSON file like the following.
Summary
I introduced an example of creating custom REST resources in Drupal. I hope this serves as a reference when creating custom resources.
I also plan to continue implementing the IIIF Presentation API and create a module similar to Omeka S’s IIIF Server.