DNS has a rarely used class next to the usual IN: CH, for CHAOS. Many servers answer a TXT query for version.bind in that class with their software name and version.
dig @a.iana-servers.net CH TXT version.bind +short
dig @9.9.9.9 CH TXT version.bind +short
dig @192.0.2.53 CH TXT version.server +short
The answers vary a lot. One server says "Knot DNS 3", a public resolver may return its own build tag, and many return nothing or a refusal. version.server is a newer name for the same question that some servers prefer.
I’d mainly use this on servers you run yourself. It is a quick way to see whether an upgrade of BIND, Unbound or a Pi-hole’s FTL really landed, without logging in. It also shows what an outsider can learn, which is the security side of it: a precise version string makes it easier to match known bugs.
So for a server that faces the internet, I would hide or replace the string. BIND takes version "none"; in its options, and Unbound has hide-version: yes. Do not take the answer as proof of anything either: the string is whatever the admin configured, so it can be blank, fake or a joke. And the query only works when you aim it at a specific server with @.
Further reading: dig manual (BIND 9), Unbound: unbound.conf
Going deeper: Guide: dig for beginners, look up DNS records and read the answer