If the cylinder is fully extended, and if the top of the cylinder (IE, at the bottom of the ram) is laterally supported, you should be able to use the effective length as the actual length of the rod, with K = 1.
If the cylinder is partially extended, and if the top of the cylinder is laterally supported, you should be able use the effective length as the larger of the rod lengths outside or inside the cylinder.
If the cylinder is pinned at the bottom, ram is pinned at the top, and the top of the cylinder is unsupported, you'd need to consider the whole cylinder as a unit for the buckling analysis, and it won't be as simple as plugging numbers into a formula.
In either of the first two cases, Euler's equation may not do much for you. It is applicable to "long" columns, and hydraulic cylinders tend to be shorter. There are various sources for shorter column design loads, one source being a good Strength of Materials textbook.
In either of the first two cases, the design of the piston itself may allow you to consider one end of the ram as fixed or partly fixed, which would reduce the effective length.