I know how domain name system (DNS) works a bit. But don't know if providers of public DNS like Google or Cloudflare can know my IP address.
If your system or application is setup to query a public DNS provider like Google (22.214.171.124) or Cloudflare (126.96.36.199), then your system sends a request to their DNS server and expects an answer back. The latter requires that the DNS server knows where to send the answer to - hence it needs to know your public visible IP address.
If you use a VPN to connect to the DNS server then this public visible IP address is not the one given by your ISP though, but the one from your VPN provider. In this case the VPN provider needs to know the public IP given by your ISP though in order to send the traffic back.