Sure. Absolutely you “can”.
The better question might be “Do you really want to?” In case of fire or other necessary emergency access requirements to the room, you could cost valuable time hunting down a key or trying to break down the door.
I wouldn’t recommend keyed access inside a residence unless this was for a separate apartment or other separate living quarters – where another access is also available.
You may want to consult with your local building code enforcement whether the local building code allows this. Though I’m not aware of any such restrictions.