To extend Thunders answer, The "knob" is just a piece of plastic, metal! But the electronic component that do the work is a potentiometer.
And the longer answer is, it depends! Some Raspberry Pi versions doesn't have a analogue output.
If there is a sound (analogue) output it is controlled by the OS but of course you can add a volume potentiometer between the low signal output and a amplifier, see
https://discord.com/channels/818384379197784084/1263039419309359237 for more guideance as it is similar to your question.