Do you use the same keyword you would/have used on your website posts but just change the article some?
no!
You always use different articles that target different keywords. So, if you're going to contact 10 sites to ask for a link you are going to create 10 different articles, on 10 different keywords. You can repeat some of the keywords if you want, but if the owners / editors of the sites with identical keywords find out that you've sent article on the same keyword to 2+ different people you might get your links removed, guest posts rejected / deleted, or be put on a blacklist (eg. scumbags

) in the future. So, it's best to simply craft 100% unique content around 100% unique keywords for every site that you contact.
This guide can help you figure out what to write about in your guest posts:
https://ahrefs.com/academy/seo-training-course/lesson-3-4
The part that interests you starts around the 11:40 mark, but I highly recommend that you watch the entire clip as you'll learn a lot about link building... Oh, and also watch the next clip in the series too, as that one's insightful too
I'm concerned with wasting good keywords for backlinks that may or may not get indexed.
if you approach good sites (that google trusts) your guest posts will get indexed. But yeah, you will "waste" (not really waste) some of those keywords, but this is the trade-off you have to make with guest posting if you wish to land quality backlinks. The sites that you want links from are as important (if not MORE important than) as yours, so you can imagine how cheeky and arrogant you will sound if you contact someone that has a better site than yours asking them to link back to your site from a post on generic keywords like, for example: what is SEO...
No one in their right mind will accept a guest post on such a broad and generic topic when they can probably write it 10 times better than you since they're already experts in their industry since they have such good sites. So, if you want quality backlinks you'll have to provide quality content around quality keywords, this is the price you have to pay (pun intended)