The low-frequency (LF) timing noise contaminates residuals of time-of-arrivals (TOAs) of pulsar signals on long time intervals and in some cases can be explained by external astronomical factors not intrinsically related to the pulsar itself. A number of millisecond pulsars located in globular clusters show the LF noise presence in their rotational phase. We discuss a possible origin of this noise as caused by random time variations in the Shapiro time delay caused by flybys of stars of the globular cluster passing near the pulsar line of sight. The Shapiro time delay is integrated over space of parameters characterizing statistical ensemble of stars in the globular cluster and its long-term indeterministic time variation is obtained. We use this result for numerical simulations of the autocovariance function of the LF timing noise and show it can be used for the measuring of the density profile distribution in the globular cluster.