The pipefail shell option is specific to a number of shells that shellcheck claims to support1. You can use this shell option and be portable, if by "portability" you assume that any target system has a shell that supports it (and any other constructs that you may be using). This is the same type of "portability" that you get with any other specific scripting language.
The shellcheck linter will complain if it finds set -o pipefail in a shell script that is a sh script, since it's currently not supported by POSIX sh.
To ensure that your script is a script interpreted by the bash shell (or any specific shell that you are coding for), the script should have a #!-line pointing to the correct shell interpreter, e.g.,
#!/bin/bash
or possibly
#!/usr/bin/env bash
or something similar.
With a proper #!-line that additionally indicates that the script will be interpreted by a particular shell that is not sh, the shellcheck linter will not complain about you setting the pipefail shell option in your script.
If you don't use a #!-line in your scripts, then you should consider doing so (or always run your scripts with an explicit interpreter on the command line). Meanwhile, the shellcheck command line tool can be told to switch to mode using its -s (or --shell=) option:
shellcheck --shell=bash myscript
1I suspect that shellcheck has a "POSIX sh mode" and an "other mode" to support bash, dash, and ksh (shellcheck does not claim to support zsh). The pipefail shell option is documented to work with bash, and ksh. The zsh shell has a PIPE_FAIL shell option that can be set in the same way. The dash shell does not support the option, but if the #!-line mentions dash, shellcheck won't complain about pipefail.
set -o pipefailis not defined in the current POSIX.1-2017: pubs.opengroup.org/onlinepubs/9699919799/utilities/…