Instructions adapted from this thread: https://discourse.pi-hole.net/t/use-dns-to-force-youtube-into-restricted-mode-and-pi-hole/1996/23
Add these to /etc/hosts
216.239.38.119 restrictmoderate.youtube.com
216.239.38.120 forcesafesearch.google.com
204.79.197.220 strict.bing.com
52.149.247.1 safe.duckduckgo.com
2001:4860:4802:32::77 restrictmoderate.youtube.com
2001:4860:4802:32::78 forcesafesearch.google.com
create this file /etc/dnsmasq.d/05-restrict.conf with these lines
# YouTube
cname=www.youtube.com,restrictmoderate.youtube.com
cname=m.youtube.com,restrictmoderate.youtube.com
cname=youtubei.googleapis.com,restrictmoderate.youtube.com
cname=youtube.googleapis.com,restrictmoderate.youtube.com
cname=www.youtube-nocookie.com,restrictmoderate.youtube.com
# SafeSearch
cname=www.google.com,forcesafesearch.google.com
# Bing Family Filter
cname=www.bing.com,strict.bing.com
# DuckDuckGo Filter
cname=www.duckduckgo.com,safe.duckduckgo.com
cname=duckduckgo.com,safe.duckduckgo.com
Finally restart PiHole. Tested with PiHole 5.1.2