It may be invented, but not by him. It is at least as old as the 1997 film Contact.
https://vimeo.com/188517388
The description blurb reads:
"Since Apollo 13 many people have asked me, 'Did you have suicide pills on board?' We didn't, and I never heard of such a thing in the eleven years I spent as an astronaut and NASA executive," - Jim Lovell, commander of the ill-fated Apollo 13 mission.
For this scene, from the movie "Contact", based off his book, I guess Carl Sagan got inspiration from the Soviet Voskhod 2 mission. Cosmonaut Alexey Leonov said he was given a suicide pill by the authorities, in the event that he might get stuck outside of the Voskhod spacecraft while attempting the very first "spacewalk" or EVA (extra-vehicular activity).
For NASA's options, Gerry Griffin, a former director of the Johnson Space Center in Houston, Texas, corroborated Lovell's statement, bluntly adding that if an astronaut truly wished to end his or her life, space provides plenty of opportunities. Outer space is just as effective a suicide agent as a cyanide capsule, perhaps even more so. Exposure to its empty vacuum often results in a blissful loss of consciousness in a matter of seconds. Death by asphyxiation usually follows within two minutes. (from http://www.realclearscience.com/blog/2013/10/astronauts-and-suicide-pills.html)
Uploaded on Oct 23, 2016 at 5:36 am
As for the 2013 link, it reads that although the Americans weren't issued suicide capsules, at least one Soviet had one (although he didn't say if it was issued by the space program vs him just carrying it with him of his own accord).