In the Master Page(s).
Create a new text frame large enough to hold the longest page number and any text you want to appear next to it. Position the text frame where you want the page number to appear (left, right or centred) and format it (choose typeface and size). If your document has facing pages, create separate text frames for the left and right master pages.
Then Type > Insert Special Character > Markers > Current Page number.