TL;DR He didn't
I purchased One Giant Leap to research your question; a complete quote from the section you reference is here:
Dave Scott was one of the main points of contact between the
astronauts and MIT, and he developed great affection for the Apollo
computer, and also the ability to add his own programs to it, which he
did as commander of Apollo 15. "How do you take a pilot, put him in
a spaceship, and have him talk to a computer? That's not easy, in real
time," Scott said. "[The onboard computer] was, with its computational
ability, a joy to operate. It was just a tremendous machine. It was so
simple and straightforward that even pilots could learn how to use
it."$^\text{70}$
Reference 70 is:
Scott, "Speech at the Opening of the Computer Museum."
Not very helpful, as far as I can find, he did not speak at the opening of the Computer History Museum in Mountain View, California.
However, searching the excerpts of his speech leads me to an older book (published 23 years before), "Journey to the Moon (Library of Flight)" by Eldon C Hall with a larger excerpt,
We also had this panel that was operated by the crew, and great
debates occurred relative to what it should look like. How do you talk
to a computer? How do you take a pilot, put him in a spaceship and
have him talk to a computer? That is not easy in real-time. Somebody
at MIT came up with the verbnoun concept, but I'm surprised that it is
not utilized in other computers today. It was very simple for us to
operate with a series of two-digit numbers representing verbs and
another series of two-digit numbers representing nouns. It was so
simple and straightforward that even pilots could learn how to use it.
$^\text{5}$
Digging into that reference gives us:
Astronaut David Scott, Commander of Apollo 15. From the transcript of Scott's address "The User's Point of View," presented at the Boston Computer Museum's inaugural, 1982.
I tracked this down with the assistance of Massimo Petrozzi from the Computer History Museum. The original talk is on Youtube here. I got it transcribed, and you can see the transcription here. The transcription posted by Star Man is close. It definitely comes from the same event, and it looks like it was just cleaned up for distribution.
Scott talks about his experiences with the Apollo Guidance Computer and talks programs and extensions to the computer, but he never mentions adding them himself. He did, however, talk about the extensive testing and review the software went through and that it needed to get a lockdown and committed to physical rope memory weeks before launch.
The cited reference does not support the claim made by the text.
Scott was the astronaut representative to MIT, who wrote the AGC software. There is even a memo written by him after his moon landing, with several very specific improvements to the LUMINARY (Lunar Lander) software, referred to as "famous" in another memo. However, as far as I can find, he did not write code and did not program the AGC. However, he did work closely with the team that did.