You should take a look at this thread:
Learning to pledge() an application - a story
and
Both are all ready there in a default installation.
https://www.openbsd.org/faq/pf/config.html
-----------------------------------------------
https://man.openbsd.org/pledge.2