Thank you very much for your replies! The code that Greg A. suggested worked fine after a bit of tweaking! It was exactly what I was looking for!
I’m very thankful for that, but now I ran into an unexpected problem- if the entry isn’t published with a category at all, it doesn’t show up. I could solve it by telling the client always to tag an entry with a category, but probably they won’t always remember to do it. That’s why I originally tried to make the publishing as simple as possible- if an entry is meant for anyone to see, no category needed, just publish. If an entry is meant for one of the two specific member groups, then a category is added, and logging in is needed to see it.
Is it then so that after the {categories} tag is used in EE, it only cares about entries with a category added and disregards and doesn’t show the other entries that are without a tag? Below is the final code that worked otherwise. Note that the {content} tag, which is my main content is between the {categories} tag. Does that make a difference?
{if logged_in}
{exp:weblog:entries orderby="date" sort="desc" limit="1" weblog="{my_weblog}"}
{if member_group == "3"}
{categories show="not 6"}
{content}
{/categories}
{if:else}
{content}
{/if}
{/exp:weblog:entries}
{if:else}
{exp:weblog:entries orderby="date" sort="desc" limit="1" weblog="{my_weblog}"}
{categories show="not 5|6"}
{content}
{/categories}
{/exp:weblog:entries}
{/if}