Preheat oven to 350°F. Grease a 9x13-inch baking dish lightly with butter or nonstick spray.
In a large bowl, whisk together cream of mushroom soup, milk, soy sauce, and black pepper until smooth.
Add the drained green beans to the bowl and stir until well coated. If using fresh beans, blanch for 5 minutes in boiling water, then drain before mixing.
Pour half of the bean mixture into the prepared dish. Sprinkle half of the fried onions (and cheese, if using) over the top. Add the remaining beans, then smooth out the surface.
Bake uncovered for 25 minutes, until bubbling around the edges.
Sprinkle the remaining fried onions (and cheese if desired) over the top. Return to the oven for 10–12 minutes, until the topping is golden brown and crisp.
Let rest for 5 minutes before serving.