I got this error while running as a non-root user:
$ pkg which /usr/local/lib/libgltf-0.0.so
pkg: sqlite error while executing PRAGMA user_version; in file pkgdb.c:2443: attempt to write a readonly database
IMO, pkg which should be a read-only operation, it shouldn't attempt to write.
pkg-1.11.1 on FreeBSD 12 amd64