That か simply means “or.” It connects A and B below.
A: うらやましがられる
B: 無邪気な気まぐれだと、困った顔をされる
Both are using the final verb in the passive voice. We get the following by converting them back into the active voice.
A’: うらやましがる
B’: 無邪気な気まぐれだと、困った顔をする
These are two things other people might do to the person who declared they are a witch. It is they who get envious or make a troubled face, not the person who made the declaration. The passive forms above describe this from the perspective of the person who made the declaration. That person might receive such reactions from other people.
だと consists of だ and と.
と quotes the preceding part. Some verb like 思う is omitted after と. It is also other people who think it (= the declaration) is an innocent, or childish, whim.
だ is the plain form of です. Since 気まぐれ is a noun (or a na-adjective), it is usually followed by だ when it comes at the end of a quoted clause (though it is sometimes omitted).
B’’: 「無邪気な気まぐれだ」と(思って)、困った顔をする
So what the sentence is saying is something like this.
Nowadays, even if you declared, “I am a witch,” there would no danger. At most, peoplePeople would express their envy or, at most, make a troubled face thinking it is a childish whim.