If you’re flying, fly in and out of Jackson. Spend a couple days in Teton NP then Yellowstone. If you only have 5-7 days I’d stay inside the park, have a plan for every day and get on the road as early as possible it will be crowded and traffic jams mostly because of bears and buffalo in summer.
If you have more time, flying in or driving in. I’d say outside the park in Jackson, then West Yellowstone, Gardner, Cooke City, Red Lodge, Cody and back to Jackson.
If it’s your first time book your lodging 6 months out.