Pf is included in FreeBSD and macOS, and by extension pfsense. But it's worth noting that they've all diverged to varying degrees so you've gotta be careful in terms of syntax and features.
For fun I've been monkeying around with a friendly pf library in everyone's favorite language, and the differences between bit me a few times… although it looks like FreeBSD-current is starting to work towards convergence. It's a really powerful tool, it'll let you write rules conditional on an OS fingerprint, handle a bunch of traffic normalization… but it's also been a reminder about how much I dislike C APIs (obviously most folks are going to be using pfctl which is just fine and dandy).
https://nostarch.com/pf3
OpenBSD's PF firewall has been adopted by Solaris, and I believe it is an option in FreeBSD and Linux.
https://en.wikipedia.org/wiki/PF_(firewall)