The 51-year-old, who coached at Burnley last season, will replace Ian Woan in the role after the former Nottingham Forest winger left for Watford.
Cotterill said: "Stuart is going to be replacing Woany. I have known Stuart for a long, long time. He is a good organiser and a good coach. He left Burnley a couple of months ago and I am really pleased to have him on board.
"Stuart has been here a few days and fitted in very well. He's got a spring in his step and made a good impression. I think the lads have taken to him already."
Gray's most high-profile position came in 2001 when he took over as manager of then-Premier League club Southampton for 115 days.