In Instant Pot, combine sugar, flour, and cocoa powder. Whisk dry ingredients together. If making gluten-free, simply omit flour and add 1½tbsp. cornstarch.
Select Sauté mode and add milk and butter. Bring fudge to a boil while stirring gently. Let boil for 2 minutes.