Density Control of Multi-Agent Systems with Safety Constraints: A Markov Chain Approach