The 22-year-old former Scotland Under-21 international made five appearances on loan with the Shrimpers in 2016.
He was let go by West Ham this summer, failing to make a senior appearance since joining from Hamilton in 2015.
"I came here on loan for a short spell and it's a great club, I can't wait to start playing," he said.
Find all the latest football transfers on our dedicated page.
League One side Southend United have re-signed former West Ham left-back Stephen Hendrie on a two-year contract, with the option of a third.