There is scriptSig and scriptPubKey. And when you provide scriptPubKey you provide your public key and some opcodes are added. But when you provide scriptSig what do you sign?
I wrote it in 2019 so it's not up-to-date with taproot & co, but maybe it can someway help you, as far as you are starting from the bases:
https://github.com/baro77/btcUnlockingLockingScriptCS