That is less silly of an answer than you might think; SHA-3-256 is a function from bitstrings (or bytestrings) to 256 bit hashes; it has no predefined ideas about a mapping of an integer to those bitstrings; it'll work for any of them.
Now, the application which is using SHA-3 might have such a predefined idea, and hence might define a 'correct' way. However, there is nothing in the code segment above would define it, and we have no idea what application you are attempting to be compatible with.
If you have no predefined application, and are just looking for a plausible way, might I suggest converting the integer into a little-endian 4 byte string (or 8 byte, if the integer value might be above 4 billion). That's as good as any...