Thailand's monarch has endorsed a new constitution in the first step back towards democracy after a 2014 military coup.