Italy striker Scamacca, David Moyes' marquee summer signing from Sassuolo, netted a first-half header on his full debut in the Europa Conference League qualifying play-off.
Jarrod Bowen added a second after the break before Viborg pulled one back through Jakob Bonde's header.
That could have made next week's second leg in Denmark a little hairy, but Michail Antonio gave the Hammers - Europa League semi-finalists last season - some breathing space as they bid to reach the group stages.
Manager David Moyes was suspended - along with Declan Rice and Aaron Cresswell - and watched from the stands as assistant Billy McKinlay took over touchline duties.
"I could feel the heat on the back of my neck," smiled McKinlay.
"He's a manager of stature and presence and we need him leading the troops so it was strange to have him up there looking from afar."
The Hammers team was a mixture of new signings, senior pros and youngsters and McKinlay added: "I think the performance was a bit frustrating, a bit laboured and a bit pedestrian. Bit of a mixed bag really.
"Gianluca's probably super pleased and I'm equally as pleased. Strikers are judged by goals so to get off the mark quickly is big and there's plenty more to come from him.
"And Michail's goal was really important. At 2-0 up we had an opportunity to kick on. We did a lot of work on Viborg, and in no way thought this would be an easy gig.
"We gave away a poor goal so Michail's goal settled us down. It's a decent result I think and we'll go into the second leg with good confidence."
Viborg head coach Jacob Friis said: "We are quite happy about the game, we felt we played an even game. It's a big performance for us and we are disappointed to lose.
"We are not dead and buried yet. Maybe the hole has been dug - but we are not in it yet."