Freezing of gait (FOG) is one of the most troublesome symptoms of Parkinson’s disease, affecting more than 50% of patients in advanced stages of the disease. Wearable technology has been widely used for its automatic detection, and some papers have been recently published in the direction of its prediction. Such predictions may be used for the administration of cues, in order to prevent the occurrence of gait freezing. The aim of the present study was to propose a wearable system able to catch the typical degradation of the walking pattern preceding FOG episodes, to achieve reliable FOG prediction using machine learning algorithms and verify whether dopaminergic therapy affects the ability of our system to detect and predict FOG. Methods: A cohort of 11 Parkinson’s disease patients receiving (on) and not receiving (off) dopaminergic therapy was equipped with two inertial sensors placed on each shin, and asked to perform a timed up and go test. We performed a step-to-step segmentation of the angular velocity signals and subsequent feature extraction from both time and frequency domains. We employed a wrapper approach for feature selection and optimized different machine learning classifiers in order to catch FOG and pre-FOG episodes. Results: The implemented FOG detection algorithm achieved excellent performance in a leave-one-subject-out validation, in patients both on and off therapy. As for pre-FOG detection, the implemented classification algorithm achieved 84.1% (85.5%) sensitivity, 85.9% (86.3%) specificity and 85.5% (86.1%) accuracy in leave-one-subject-out validation, in patients on (off) therapy. When the classification model was trained with data from patients on (off) and tested on patients off (on), we found 84.0% (56.6%) sensitivity, 88.3% (92.5%) specificity and 87.4% (86.3%) accuracy. Conclusions: Machine learning models are capable of predicting FOG before its actual occurrence with adequate accuracy. The dopaminergic therapy affects pre-FOG gait patterns, thereby influencing the algorithm’s effectiveness.