dnd 5e – Can you cast a spell learned from the Magic Initiate feat using spell slots?

No, you can’t use spell slots, unless you choose the class associated with your Spellcasting feature.

Without loss of generality, suppose you are a Wizard who takes the Magic Initiate feat (PHB, p. 168), and pick the cleric class for the feat. The relevant part of the description of the feat says:

Choose a class: bard, cleric, druid, sorcerer, warlock, or wizard. You learn two cantrips of your choice from that class’s spell list.

In addition, choose one 1st-level spell to learn from that same list. Using this feat, you can cast the spell once at its lowest level, and you must finish a long rest before you can cast it in this way again.

So the 1st-level spell you choose for the feat is a cleric spell (as are the cantrips). Even if the 1st-level spell you choose for the feat is on both the cleric and wizard spell lists, it still counts as a cleric spell for you.

Unfortunately, as of the 2018 PHB errata, the wizard’s Spellcasting feature says, (emphasis mine):

The Wizard table shows how many spell slots you have to cast your wizard spells of 1st level and higher. To cast one of these spells, you must expend a slot of the spell’s level or higher.

A wizard may only cast wizard spells with their wizard spell slots. This is confirmed in the official ruling on Magic Initiative in the Sage Advice Compendium:

If you have spell slots, can you use them to cast the 1st-level spell you learn with the Magic Initiate feat?

Yes, but only if the class you pick for the feat is one of your classes. (…)

If the cleric spell chosen counted as a wizard spell for you, you would be able to cast it using your spell slots, but the SAC confirms that the class you choose for Magic Initiate must be one of your classes for this to be the case.

On the other hand, if the wizard took the Magic Initiate feat and picked the wizard class for the feat, the chosen spell would be a wizard spell for you, and would be eligible for casting with your wizard spell slots. This is confirmed in the Sage Advice Compendium ruling, which continues:

(…) Similarly, if you are a wizard and pick that class for the feat, you learn a 1st-level wizard spell, which you could add to your spellbook and subsequently prepare.

In short, you must follow your character’s normal spellcasting rules, which determine whether you can expend spell slots on the 1st-level spell you learn from Magic Initiate.

Eldritch Knight and Arcane Trickster

In particular, casting a spell with your spell slots as an Eldritch Knight fighter or Arcane Trickster rogue requires two things: that you know the spell, and that it is a wizard spell. The spell gained from Magic Initiate satisfies both of these conditions if you choose the wizard class for the feat.

The Eldritch Knight’s Spellcasting feature says (PHB, p. 75; emphasis mine):

The Eldritch Knight Spellcasting table shows how many spell slots you have to cast your wizard spells of 1st level and higher. To cast one of these spells, you must expend a slot of the spell’s level or higher. You regain all expended spell slots when you finish a long rest.

Similarly, the Arcane Trickster’s Spellcasting feature says (PHB, p. 98; emphasis mine):

The Arcane Trickster Spellcasting table shows how many spell slots you have to cast your wizard spells of 1st level and higher. To cast one of these spells, you must expend a slot of the spell’s level or higher. You regain all expended spell slots when you finish a long rest.

If you pick the wizard class for the Magic Initiate feat, and therefore the 1st-level spell you learn from the feat is a wizard spell for you, it meets all the conditions for being able to expend spell slots to cast it as an Eldritch Knight or an Arcane Trickster.

This ruling is confirmed by the same Sage Advice Compendium ruling quoted earlier (emphasis mine):

In short, you must follow your character’s normal spellcasting rules, which determine whether you can expend spell slots on the 1st-level spell you learn from Magic Initiate.

Since your Spellcasting feature says you can use your spell slots to cast wizard spells, then if you take Magic Initiate and pick the wizard class, you can cast that 1st-level wizard spell using your spell slots.